android - 三星 Galaxy S4 用户报告 BOOT COMPLETED 接收器无法工作?

标签 android broadcastreceiver boot

我在 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/

相关文章:

android - 支持 Android Camera Api 和 Camera2 Api 的问题

java - 与 Whatsapp 共享音频文件(文件格式不支持错误)

android - 当我断开 wifi 时,用于检查互联网连接的广播接收器被调用两次

android - 在 BroadcastReceiver 的 onReceive() 方法中创建 Toast

安卓游戏开发。

android - 如何使亚马逊应用内购买 (IAP) 2.0 与 Android R8 兼容

java - AlarmManager:如何安排每日闹钟和处理时间变化

linux - Derby 安 : Plymouth configuration with installed video card

linux - 在Linux中编辑vmlinuz文件

boot - GRUB2 UEFI 加载程序如何知道在哪里查找配置文件(或第二阶段的文件所在的位置)?