简体   繁体   English

华为设备未收到 Android BOOT_COMPLETED

[英]Android BOOT_COMPLETED not received in Huawei device

I am currently working on a reminder app and the BootReceiver is not executed when the Huawei device is rebooted.我目前正在开发一个提醒应用程序,并且在华为设备重新启动时不会执行BootReceiver I have tested the app in other android devices and it works perfectly, except for Huawei specific devices.我已经在其他安卓设备上测试过这个应用程序,它运行得很好,除了华为特定的设备。 I have tried the following.我尝试了以下方法。

Manifest file清单文件

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<receiver
    android:name=".BootService"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.REBOOT" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>

BootService class引导服务类

public class BootService extends BroadcastReceiver {
    private static final String TAG = "BootService Lumea";
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "Boot Completed Received: " + intent);
        Toast.makeText(context, "Boot Completed Received", Toast.LENGTH_SHORT).show();
    }
}

Would be really helpful if you guys can help me find a solution for the same.如果你们能帮我找到相同的解决方案,那将非常有帮助。

There is no doubt that there is a system broadcast in the behavior of power on.毫无疑问,开机的行为是有系统广播的。 The idea is that we can register a broadcast in our code, and it's basically a static broadcast to do this.这个想法是我们可以在我们的代码中注册一个广播,它基本上是一个静态广播来做到这一点。 Here's a sample code.这是一个示例代码。 Let's inherit a broadcastreceiver and find a fixed action, that is, get the android.intent.action .BOOT_ Completed, make a logical judgment in it.我们继承一个broadcastreceiver,找到一个固定的action,也就是拿到android.intent.action .BOOT_Completed,在里面做个逻辑判断。 Here is skill link https://blog.csdn.net/u011174639/article/details/106120684?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1这里是技能链接https://blog.csdn.net/u011174639/article/details/106120684?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM