Java 类android.app.IntentService 实例源码

项目:Android-Developer-Toolbelt    文件:MemoryServiceWriter.java   
@Override
public void writeSource(Writer writer) throws IOException {

    TypeSpec typeSpec = TypeSpec.classBuilder(getSimpleName())
            .superclass(ClassName.get(IntentService.class))
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .addField(createFieldMessenger())
            .addField(createFieldAllocations())
            .addField(createFieldRun())
            .addMethod(createConstructor())
            .addMethod(createOnBind())
            .addMethod(createOnHandleIntent())
            .build();

    JavaFile javaFile = JavaFile.builder(PACKAGE, typeSpec)
            .addFileComment("Generated by MemoryServiceWriter.java. Do not modify!")
            .build();

    javaFile.writeTo(writer);
}
项目:AndroidApkMaker    文件:AndroidApkMaker.java   
public AndroidApkMaker(IntentService service, 
                       NotificationManager mNotifyManager, 
                       NotificationCompat.Builder mBuilder){
    this.service = service;
    this.mNotifyManager = mNotifyManager;
    this.mBuilder = mBuilder;
}
项目:WorkflowyList    文件:AppWidgetUtils.java   
public static void enqueueForService(Context context, Class<? extends IntentService> clazz, int appWidgetId, String action, Map<String, String> extraStrings) {
    Intent intent = new Intent(context, clazz)
            .setAction(action)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

    fillIntent(intent, extraStrings, null);
    context.startService(intent);
}
项目:android-injection    文件:AndroidResourceInjector.java   
AndroidResourceInjector(T object, Object... possibleParents) {
    super(possibleParents);
    this.object = object;
    getTopClasses().add(Application.class);
    getTopClasses().add(Fragment.class);
    try {
        getTopClasses().add(Class.forName("android.app.Fragment"));
    } catch (ClassNotFoundException ignored) {

    }
    getTopClasses().add(IntentService.class);
    getTopClasses().add(Service.class);
    getTopClasses().add(AppCompatActivity.class);
    getTopClasses().add(Activity.class);
}
项目:FullRobolectricTestSample    文件:IntentServiceTest.java   
@Test
public void shouldSetIntentRedelivery() {
  IntentService intentService = new TestIntentService();
  ShadowIntentService shadowIntentService = shadowOf(intentService);
  assertThat(shadowIntentService.getIntentRedelivery()).isFalse();
  intentService.setIntentRedelivery(true);
  assertThat(shadowIntentService.getIntentRedelivery()).isTrue();
  intentService.setIntentRedelivery(false);
  assertThat(shadowIntentService.getIntentRedelivery()).isFalse();
}
项目:JourneyApp    文件:LocationService.java   
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (isServiceRunning()) {
        // Do not call super i.e. do not call onHandleIntent
        return IntentService.START_NOT_STICKY;
    }
    singletonLocationService = this;

    Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();

    int resultCode = GooglePlayServicesUtil
            .isGooglePlayServicesAvailable(this);

    if (resultCode != ConnectionResult.SUCCESS) {
        Toast.makeText(this, R.string.noGooglePlayServices,
                Toast.LENGTH_LONG).show();

        // Do not call super i.e. do not call onHandleIntent
        return IntentService.START_NOT_STICKY;
    }

    locationClient = new LocationClient(this, this, this);
    locationClient.connect();

    if (!openOutputFile()) {
        // Do not call super i.e. do not call onHandleIntent
        return IntentService.START_NOT_STICKY;
    }

    JourneyPreferences.registerOnSharedPreferenceChangeListener(this, this);
    setForegroundNotification();

    return super.onStartCommand(intent, flags, startId);
}
项目:android-wg-planer    文件:GeofenceActivityHelper.java   
public GeofenceActivityHelper(Activity activity, List<Geofence> geofences, Class<? extends IntentService> intentService, @InitialTrigger int initialTrigger) {
    super(activity, geofences, intentService, initialTrigger);
    this.activity = activity;
    update();
}
项目:android-wg-planer    文件:GeofenceActivityHelper.java   
public GeofenceActivityHelper(Activity activity, List<Geofence> geofences, Class<? extends IntentService> intentService) {
    super(activity, geofences, intentService);
    this.activity = activity;
    update();
}
项目:android-wg-planer    文件:GeofenceHelper.java   
public GeofenceHelper(Context context, List<Geofence> geofences, Class<? extends IntentService> intentService, @InitialTrigger int initialTrigger) {
    super(context);
    mGeofences = new ArrayList<>(geofences);
    mIntentService = intentService;
    mInitialTrigger = initialTrigger;
}
项目:android-wg-planer    文件:GeofenceHelper.java   
public GeofenceHelper(Context context, List<Geofence> geofences, Class<? extends IntentService> intentService) {
    this(context, geofences, intentService, INITIAL_TRIGGER_NONE);
}
项目:android-injection    文件:IntentServiceInjector.java   
public IntentServiceInjector(IntentService object, Object... possibleParents) {
    super(object, possibleParents);
}
项目:FullRobolectricTestSample    文件:ShadowIntentService.java   
@Implementation
public void setIntentRedelivery(boolean enabled) {
  mRedelivery = enabled;
  directlyOn(realIntentService, IntentService.class, "setIntentRedelivery", boolean.class)
      .invoke(enabled);
}
项目:FullRobolectricTestSample    文件:Robolectric.java   
public static ShadowIntentService shadowOf(IntentService instance) {
  return (ShadowIntentService) shadowOf_(instance);
}