コード例 #1
0
  public void test_startService_succeeds() throws RemoteException {
    Mockito.when(context.startService(Mockito.any(Intent.class))).thenReturn(COMPONENT_NAME);

    boolean success = wrapper.startService();

    assertTrue(success);
  }
コード例 #2
0
  public void test_startService_fails() throws RemoteException {
    Mockito.when(context.startService(Mockito.any(Intent.class))).thenReturn(null);

    boolean success = wrapper.startService();

    assertFalse(success);
  }
コード例 #3
0
  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);
  }
コード例 #5
0
 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);
 }