首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JobIntentService不调用OnHandleWork

JobIntentService不调用OnHandleWork
EN

Stack Overflow用户
提问于 2020-01-30 10:34:52
回答 1查看 188关注 0票数 0

我用静态方法JobIntentService定制了enqueueWork。

代码语言:javascript
复制
public static void enqueueWork(@NonNull Context context, @NonNull Intent intent) {        
            enqueueWork(context, MyJobIntentService.class, JOB_ID, intent);       
    }

此外,我还定制了FirebaseMessagingService的实现。当我从FCM收到推送通知时,我调用我的JobIntentService.的enqueueWork

代码语言:javascript
复制
MyJobIntentService.enqueueWork(context, new Intent());

但是OnHandleWork 并没有调用Android8.0和更高版本的。我的manifest.xml。

代码语言:javascript
复制
<service android:name="com.company.MyJobIntentService"
            android:permission="android.permission.BIND_JOB_SERVICE" />

你知道为什么它不能正常工作吗?谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-14 04:56:28

没什么不对的。不幸的是,JobIntentService无法在Android8.0和更高版本上立即运行。

代码语言:javascript
复制
When running as a pre-O service, the act of enqueueing work will generally start the service immediately, regardless of whether the device is dozing or in other conditions. When running as a Job, it will be subject to standard JobScheduler policies for a Job with a setOverrideDeadline(long) of 0: the job will not run while the device is dozing, it may get delayed more than a service if the device is under strong memory pressure with lots of demand to run jobs.

在测试时,我新建了一个空项目,它在调用时立即运行,但是当我在一个真正复杂的项目中使用时,它会在调用后几分钟后运行。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59984013

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档