我在 Play 商店中的一个应用程序有一个BOOT_COMPLETED
接收器,它在 S4 之前从未出现过任何问题,我收到了来自 S4 用户的多封电子邮件,说该应用程序无法正常工作经过一些故障排除后,BOOT_COMPLETED
接收器未被调用。
这里有人知道如何为这个特定设备解决这个问题吗?
主要代码如下:
public class BootCompletedIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
...
...
//ALL MY CODE IS HERE
...
...
}
}
}
list :
<receiver android:name=".BootCompletedIntentReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
当然我有正确的权限:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
最佳答案
BOOT_COMPLETE 在安装外部存储之前发送。如果应用程序安装到外部存储,它将不会收到 BOOT_COMPLETE 广播消息。为防止这种情况,您可以将应用程序安装在内部存储中。您只需在 menifest.xml 中添加这一行即可。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="internalOnly"
... >
某些 HTC 设备可以启用“快速启动”功能,该功能更像是深度休眠而不是真正的重启,因此不应提供 BOOT_COMPLETE Intent 。要恢复它,您的接收器会喜欢这样:
<receiver
android:name="YOUR_FULL_PACKAGE_NAME.BootStartUpReciever"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
此过程适用于我的Samsung Galaxy SM-T235Y Tab4,但不适用于Samsung GT-S7852 手机。相关Thread is here
关于android - 三星 Galaxy S4 用户报告 BOOT COMPLETED 接收器无法工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17240316/