How to cancel JobIntentService

How can I cancel JobIntentService ? I do not see such methods in the documents, except, perhaps, from the JobSheduler API and the Context#stopService(...) method, which I'm not sure if this is correct.

+7
android android-support-library
source share
2 answers

JobIntentService only brings IntentService to Android 8+, which is more strict regarding background services. It works like the old IntentService on devices with older versions of Android.

IntentService never intended to be canceled , so the absence of any API to cancel JobIntentService .

Therefore, JobIntenService should only be used for work that does not need to be undone. Please note: JobIntentService can still be used for work that may fail and therefore be interrupted.

Work that can be undone must be done either:

  • An Activity (or its ViewModel ) for short work
  • JobService (using Firebase Job Manager or Job Scheduler if minSdk is 21)
  • User foreground mode
0
source share

Prior to Android 8.0, JobIntentService implemented as an IntentService . IntentService does not stop and does not accept any other requests through any action until its onHandleIntent method completes the previous request. stopService () will not be called until the task is completed. And it is automatically called when it is. This IntentService But this question has already been answered regarding IntentServices , hope this helps.

answered the question

also check out android developers

+1
source share

All Articles