华为设备未收到Android BOOT_COMPLETED

问题描述 投票:0回答:1

我当前正在使用提醒应用程序,并且重新启动Huawei设备时未执行BootReceiver。我已经在其他Android设备上测试了该应用程序,并且除了Huawei特定设备外,它都能正常运行。我已经尝试了以下方法。

清单文件

<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类

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();
    }
}

如果你们能帮助我找到相同的解决方案,那将真的很有帮助。

android intentfilter alarm reboot huawei
1个回答
0
投票

毫无疑问,在开机行为中存在系统广播。这个想法是我们可以在代码中注册一个广播,并且基本上是一个静态广播。这是示例代码。让我们继承一个Broadcastreceiver并找到一个固定的动作,即,完成android.intent.action .BOOT_,并在其中做出合理的判断。这是技能链接https://blog.csdn.net/u011174639/article/details/106120684?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1

© www.soinside.com 2019 - 2024. All rights reserved.