微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,Class<? extends IntentService> intentService) {
    super(activity,intentService);
    this.activity = activity;
    update();
}
项目:android-wg-planer    文件GeofenceHelper.java   
public GeofenceHelper(Context context,@InitialTrigger int initialTrigger) {
    super(context);
    mGeofences = new ArrayList<>(geofences);
    mIntentService = intentService;
    mInitialTrigger = initialTrigger;
}
项目:android-wg-planer    文件GeofenceHelper.java   
public GeofenceHelper(Context context,Class<? extends IntentService> intentService) {
    this(context,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);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。