Custom JobIntentService onHandleWork not called

前端 未结 12 1172
-上瘾入骨i
-上瘾入骨i 2020-12-09 08:27

I recently was updating an app that I work on to handle notifications from push using a JobIntentService instead of a regular IntentService because

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 08:50

    I ran into this issue trying to enqueue the JobIntentService using JobScheduler. While JobScheduler has its own enqueueWork() method, it doesn't work with JobIntentService. The service will start but onHandleWork() is never called.

    It started working again when I used the static enqueueWork() method that is on the JobIntentService - eg:

    MyJobIntentService.enqueueWork(context, ...)
    

    None of this was obvious from reading Android's javadoc.

提交回复
热议问题