【问题标题】:Receivers not receiving intents after boot on Galaxy S5 (on battery only!)在 Galaxy S5 上启动后接收器未接收到意图(仅使用电池!)
【发布时间】:2016-06-14 00:15:43
【问题描述】:

我正在尝试让BOOT_COMPLETED 接收器在 Galays S5 Neo 设备(运行 5.1.1)上工作,以便在设备完全启动后立即启动服务。

所以在我定义的清单中

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

还为BOOT_COMPLETED意图添加了一个接收器

<receiver android:name="com.xyzMyApp.BootCompleteReceiver" >
    <intent-filter android:priority="999" >
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

无论是否使用电池,这几乎适用于所有设备。在 Galaxy S5 Neo 上,这仅在设备连接到开机启动时工作。如果我使用电池供电的设备并重新启动,最多可能需要 5 分钟才能收到意图。

我还尝试接收其他广播,例如 android.net.wifi.RSSI_CHANGEDandroid.intent.action.USER_PRESENTandroid.intent.action.TIME_TICK 可能将它们用作引导完成事件的替代品。想法是这些事件经常发生,因此在重新启动后不会花费很长时间,直到其中一个接收器被触发。事实证明,行为是相同的,使用电池可能需要几分钟,直到任何接收器接收到任何意图。

我还为我在系统设置中找到的应用禁用了各种电池优化,但这并没有解决问题。

感谢您的每一个提示或想法。

【问题讨论】:

    标签: android broadcastreceiver android-manifest intentfilter


    【解决方案1】:

    尝试添加QUICKBOOT_POWERON,因为某些设备在接收BOOT_COMPLETED广播时有issues

    <receiver android:name="com.xyzMyApp.BootCompleteReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>
    

    还请确保您的应用未安装在外部存储(SD 卡) 上,如建议 on this answer

    【讨论】:

    • 谢谢,我试过了,这似乎不是 bootup_completed 问题,因为启动后没有任何事件立即起作用,不仅是启动事件
    猜你喜欢
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多