@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); }
public AndroidApkMaker(IntentService service, NotificationManager mNotifyManager, NotificationCompat.Builder mBuilder){ this.service = service; this.mNotifyManager = mNotifyManager; this.mBuilder = mBuilder; }
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); }
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); }
@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(); }
@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); }
public GeofenceActivityHelper(Activity activity, List<Geofence> geofences, Class<? extends IntentService> intentService, @InitialTrigger int initialTrigger) { super(activity, geofences, intentService, initialTrigger); this.activity = activity; update(); }
public GeofenceActivityHelper(Activity activity, List<Geofence> geofences, Class<? extends IntentService> intentService) { super(activity, geofences, intentService); this.activity = activity; update(); }
public GeofenceHelper(Context context, List<Geofence> geofences, Class<? extends IntentService> intentService, @InitialTrigger int initialTrigger) { super(context); mGeofences = new ArrayList<>(geofences); mIntentService = intentService; mInitialTrigger = initialTrigger; }
public GeofenceHelper(Context context, List<Geofence> geofences, Class<? extends IntentService> intentService) { this(context, geofences, intentService, INITIAL_TRIGGER_NONE); }
public IntentServiceInjector(IntentService object, Object... possibleParents) { super(object, possibleParents); }
@Implementation public void setIntentRedelivery(boolean enabled) { mRedelivery = enabled; directlyOn(realIntentService, IntentService.class, "setIntentRedelivery", boolean.class) .invoke(enabled); }
public static ShadowIntentService shadowOf(IntentService instance) { return (ShadowIntentService) shadowOf_(instance); }