【问题标题】:Android BOOT_COMPLETED not received in Huawei device华为设备未收到 Android BOOT_COMPLETED
【发布时间】:2020-01-16 12:10:16
【问题描述】:

我目前正在开发一个提醒应用程序,当 Huawei 设备重新启动时,BootReceiver 未执行。我已经在其他 android 设备上测试过该应用程序,它运行良好,除了 华为 特定设备。我尝试了以下方法。

清单文件

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

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

【问题讨论】:

  • 不是,因为我正在寻找一种解决方案,使用户不会退出应用程序并手动更改设置。
  • this 有帮助吗?
  • 你会在所有中国手机上遇到这个问题我还没有找到解决方案:((
  • 这需要用户明确更改应用程序的设置。我正在寻找一种解决方案,我们可以以编程方式将应用列入白名单,而无需在设置中进行任何用户交互。

标签: android intentfilter alarm reboot huawei-mobile-services


【解决方案1】:

毫无疑问,上电行为中存在系统广播。这个想法是我们可以在我们的代码中注册一个广播,它基本上是一个静态广播来做到这一点。这是一个示例代码。我们继承一个broadcastreceiver,找到一个固定的action,也就是拿到android.intent.action .BOOT_ Completed,在里面做个逻辑判断。 这是技能链接 https://blog.csdn.net/u011174639/article/details/106120684?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    相关资源
    最近更新 更多