How can I cancel a JobIntentService? I see no methods to do so in the docs, apart maybe from the JobSheduler
API and the Context#stopService(...)
method, which I'm unsure if it's the right way.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
JobIntentService
is only bringingIntentService
to Android 8+ that is more strict about background services. It runs like oldIntentService
s on devices with older versions of Android.IntentService
has never been designed to be cancelled, hence the lack of any API to cancel aJobIntentService
.Therefore,
JobIntenService
should only be used for work that don't need to be cancelled. Note thatJobIntentService
can still be used for work that can fail, and consequently, be aborted.Work that can be cancelled should be executed in either:
Activity
(or itsViewModel
) for short duration workPrior to Android 8.0,
JobIntentService
is implemented as anIntentService
.IntentService
does not stop or take any other requests through some intent action until itsonHandleIntent
method completes the previous request.stopService
() won't be called until the task is finished.And it's called automatically when it is. That's a feature ofIntentService
But a similar question was already answered here referring toIntentServices
, hope it helps.answered question
also check out android developers