public void test_startService_succeeds() throws RemoteException {
    Mockito.when(context.startService(Mockito.any(Intent.class))).thenReturn(COMPONENT_NAME);

    boolean success = wrapper.startService();

    assertTrue(success);
  }
  public void test_startService_fails() throws RemoteException {
    Mockito.when(context.startService(Mockito.any(Intent.class))).thenReturn(null);

    boolean success = wrapper.startService();

    assertFalse(success);
  }
  public static void execute(
      Bundle parameters, @NotNull String action, @NotNull ResultReceiver result_receiver)
      throws IllegalStateException {
    if (!isInitialized()) throw new IllegalStateException();

    ProviderAPICommand.action = action;
    ProviderAPICommand.parameters = parameters;
    ProviderAPICommand.result_receiver = result_receiver;

    Intent intent = setUpIntent();
    context.startService(intent);
  }
Пример #4
0
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    /* BR에서 BR을 호출할 수 없다.
    Intent bat = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    String s = bat.getIntExtra("level", -1) + "%";

    RemoteViews views = new RemoteViews(context.getPackageName(),
    		R.layout.batterygauge);
    views.setTextViewText(R.id.gauge, s);
    appWidgetManager.updateAppWidget(appWidgetIds, views);
    */
    Intent intent = new Intent(context, BatteryGaugeService.class);
    context.startService(intent);
  }
 private static void beginStartingService(Context context, Intent intent)
 {
     synchronized (sStartingServiceSync)
     {
         if (sStartingService == null)
             sStartingService = ((PowerManager)context.getSystemService("power")).newWakeLock(1, "StartingDockService");
         sStartingService.acquire();
         if (context.startService(intent) == null)
             Log.e("DockEventReceiver", "Can't start DockService");
     }
     return;
     exception;
     obj;
     JVM INSTR monitorexit ;
     throw exception;
 }
Пример #6
0
 public ComponentName startService(Intent service) {
   return mBaseContext.startService(service);
 }