1

I create a UploadContactsJobService that extend JobService after uploading finish I called stopCurrentJob method

  private void stopCurrentJob() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            JOB_INFO = new JobInfo.Builder(JOB_ID,
                    new ComponentName(RDApp.get(), UploadContactsJobService.class))
                    .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
                    .addTriggerContentUri(
                            new JobInfo.TriggerContentUri(CONTACTS_URI,
                                    JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS))
                    .build();
            scheduleJob(this);
        }
            jobFinished(mRunningParams, false);
    }

the Service destroyed but the application process is still running and the app still running in the background i notice this on Android Studio it , should I kill app process to prevent battery drain using this

  android.os.Process.killProcess(android.os.Process.myPid());
Ahmed Wahdan
  • 330
  • 4
  • 15
  • `Service destroyed but the application process is still running and the app still running in the background` That's natural behavior, if your app is in background that's mean your app process is running in back ground, when the user clear your app from **recent apps** your app process will killed. –  Mar 03 '18 at 11:46
  • these services start when user add or update any contacts even the app is closed so the app will not be on recent apps – Ahmed Wahdan Mar 03 '18 at 11:48
  • Thus `jobFinished(mRunningParams, true);` the 2nd param should be true instead to be rescheduled according to the back-off criteria specified at schedule-time. otherwise: you need to debug your service lifecycle. –  Mar 03 '18 at 11:57
  • I log my service. UploadContactsJobService: on stop job UploadContactsJobService: myService destroyed and i think the service is destroyed but still running – Ahmed Wahdan Mar 03 '18 at 12:15

0 Answers0