【发布时间】: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