我用静态方法JobIntentService定制了enqueueWork。
public static void enqueueWork(@NonNull Context context, @NonNull Intent intent) {
enqueueWork(context, MyJobIntentService.class, JOB_ID, intent);
}此外,我还定制了FirebaseMessagingService的实现。当我从FCM收到推送通知时,我调用我的JobIntentService.的enqueueWork
MyJobIntentService.enqueueWork(context, new Intent());但是OnHandleWork 并没有调用Android8.0和更高版本的。我的manifest.xml。
<service android:name="com.company.MyJobIntentService"
android:permission="android.permission.BIND_JOB_SERVICE" />你知道为什么它不能正常工作吗?谢谢。
发布于 2020-05-14 04:56:28
没什么不对的。不幸的是,JobIntentService无法在Android8.0和更高版本上立即运行。
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.在测试时,我新建了一个空项目,它在调用时立即运行,但是当我在一个真正复杂的项目中使用时,它会在调用后几分钟后运行。
https://stackoverflow.com/questions/59984013
复制相似问题