Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 应用程序关闭时,Firebase作业调度程序未执行_Android_Firebase_Firebase Job Dispatcher - Fatal编程技术网

Android 应用程序关闭时,Firebase作业调度程序未执行

Android 应用程序关闭时,Firebase作业调度程序未执行,android,firebase,firebase-job-dispatcher,Android,Firebase,Firebase Job Dispatcher,我已经通过firebase作业调度器设置了一个作业,它应该在X小时后执行。当应用程序打开或处于后台时,它工作正常,但当应用程序关闭时,它不工作 有太多人面临过这个问题,即使这样的问题在Github中仍然存在,但我没有找到解决方案 这是我的密码: public void setupJob(){ FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this)); final

我已经通过firebase作业调度器设置了一个作业,它应该在X小时后执行。当应用程序打开或处于后台时,它工作正常,但当应用程序关闭时,它不工作

有太多人面临过这个问题,即使这样的问题在Github中仍然存在,但我没有找到解决方案

这是我的密码:

public void setupJob(){
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
    final int periodicity = (int) TimeUnit.HOURS.toSeconds(3);
    final int toleranceInterval = 30;

    Job myJob = dispatcher.newJobBuilder()
            .setService(MyScheduler.class)
            .setTag("MY_JOB_TAG")
            .setRecurring(false)
            .setLifetime(Lifetime.FOREVER)
            .setTrigger(Trigger.executionWindow(periodicity, periodicity + toleranceInterval))
            .setReplaceCurrent(false)
            .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            .build();

    dispatcher.mustSchedule(myJob);
}
Making.setRecurrential(true)会触发它,但仅在打开应用程序后才会触发,然后即使应用程序关闭,它也会重复并正常工作


救命啊

您使用哪个版本的Android进行测试

安卓棉花糖推出了新的节能功能。其中一个功能是Doze,当设备长时间未使用时,它通过延迟应用程序的后台CPU和网络活动来减少电池消耗。第二种是appstandby,它推迟了用户最近没有与之交互的应用的后台网络活动

请参阅:


还应注意的是,一些定制Android版本(例如小米的MIUI、华为的EMUI)具有额外的权限,允许在后台运行应用程序或接收通知(例如Firebase云消息)。

那么如何使用定制Android处理它呢?