Boot Receiver not working

女生的网名这么多〃 提交于 2019-11-28 08:31:48
Remi

If you have HTC device you also need to register for "android.intent.action.QUICKBOOT_POWERON". So the entry in manifest should be:

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

On my HTC, if I turn off the device and turn it on for a while I got QUICKBOOT_POWERON and no BOOT_COMPLETED.

If I turn off the device and remove the battery for a while - I got BOOT_COMPLETED after start.

Put permission

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

Also know that in Android >= 3.1 the app gets installed in 'stopped' state and will not get boot and shutdown events until the user 'does something' with the app at least once. See this post on the topic.

Try this::

   <receiver android:enabled="true" android:exported="true"
        android:name=".OnBootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

Cheers...!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!