My BroadcastReceiver is not receiving the BOOT_COMPLETED intent after my N1 boots

前端 未结 2 413
迷失自我
迷失自我 2020-12-10 17:06

I am unable to get my BroadcastReceiver onReceive method called using the BOOT_COMPLETED intent.

AndroidManifest.xml



        
相关标签:
2条回答
  • 2020-12-10 17:28

    All the applications that receive the BOOT_COMPLETED broadcast must be installed on the internal storage because Android delivers ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device.

    To ensure that your application will be installed on the internal memory you just need NOT to declare the android:installLocation manifest attribute.

    Another option is to set the following in the manifest section: android:installLocation="internalOnly"

    You can find more information about it here.

    0 讨论(0)
  • 2020-12-10 17:39

    EDIT: Forget everything, I've found a better explanation.

    You have to define your receiver with exported = true and enabled = true

    <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver"
      android:enabled="true" 
      android:exported="true" 
    >
    

    I think that if you change this line

    <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver">
    

    for this

    <receiver android:name=".WeatherStartupReceiver">
    

    it will fix your problem.

    I tried it on one of my projects and it didn't start.

    0 讨论(0)
提交回复
热议问题