设备重新启动并强制关闭应用程序后,在Redmi和其他自定义中文ROM中未收到WorkManager doWork回调 [英] WorkManager doWork callback is not received in Redmi and other custom Chinese ROM when device got rebooted and force closed the app

查看:215
本文介绍了设备重新启动并强制关闭应用程序后,在Redmi和其他自定义中文ROM中未收到WorkManager doWork回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在后台或被刷卡杀死时,在Redmi手机中未收到推送通知.

My app is not receiving push notification in Redmi phones while the app is in the background or it got killed by swiping.

因此,我试图通过WorkManager唤醒电话,该软件可在Redmi和其他中文自定义ROM电话以外的许多电话上使用.

So I am trying to wake the phone by WorkManager which works on many phones except Redmi and other Chinese custom ROM phones.

这是我的Worker类的代码

Here is my code of Worker class

public class OpenTalkWorkManager extends Worker {

@NonNull
@Override
public Result doWork() {

    Log.i("wake_up", "Waking up now: " + System.currentTimeMillis());

    FirebaseUtils.getInstance().updateUserPresenceStatus(getApplicationContext(), "yes");

    Intent intent = new Intent("com.opentalk.WAKE_UP");
    getApplicationContext().sendBroadcast(intent);

    return Result.SUCCESS;
}

我正试图通过PeriodicWorkRequest使工作入队

I am trying to enqueue the work through PeriodicWorkRequest

PeriodicWorkRequest.Builder mPeriodicWorkRequest = new PeriodicWorkRequest.Builder(OpenTalkWorkManager.class, 4, TimeUnit.MINUTES);
    Constraints myConstraints = new Constraints.Builder()
            .setRequiresBatteryNotLow(false)
            .setRequiredNetworkType(NetworkType.NOT_REQUIRED)
            .setRequiresCharging(false)
            .setRequiresDeviceIdle(false)
            .setRequiresStorageNotLow(false)

            // Many other constraints are available, see the
            // Constraints.Builder reference
            .build();
    PeriodicWorkRequest myWork = mPeriodicWorkRequest.setConstraints(myConstraints).build();

    UUID compressionWorkId = myWork.getId();
    WorkManager.getInstance().cancelWorkById(compressionWorkId);

    WorkManager.getInstance().enqueue(myWork);

推荐答案

您正在使用哪个版本的WorkManager?我们修复了有关PeriodicWork和强制停止alpha05中应用程序的一些错误. alpha06已用尽,建议您尝试使用它.如果您仍然遇到相同的问题,请向问题跟踪器报告,并在问题跟踪器上使用可重复的测试用例.

Which version of WorkManager are you using ? We fixed a few bugs with respect to PeriodicWork and force-stopping of apps in alpha05. alpha06 is out, and I recommend you try using it. If you still have the same problem, please report back on the issue tracker with a reproducible test case on the issue tracker.

这篇关于设备重新启动并强制关闭应用程序后,在Redmi和其他自定义中文ROM中未收到WorkManager doWork回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆