0

I am developing one application in which I need to reset alarms after rebooting the device. The code is working fine in Emulator but on my mobile device which is having Android version 4.2.2 is not working.

I have set a notification on start up, the notification is shown when I run it on Emulator but not on my device.

Please help!

MCA Shah
  • 405
  • 1
  • 4
  • 10
  • Does anything show up in your logcat around the time that it should notify? – Gary Schreiner May 10 '14 at 09:30
  • 1
    Have you started your app once? I recall that some events will only be delivered when you have runned your Activity atleast once. – RvdK May 10 '14 at 09:33
  • I confirm that you have to start the app at least once on the device after installing or redeploying it, then reboot the device to be able to receive the BOOT_COMPLETE broadcast. Also, if your app is installed on external storage, the storage may be mounted after the BOOT_COMPLETE broadcast is sent so your app will not receive it in that case. – BladeCoder May 10 '14 at 09:48
  • 1
    @BladeCoder: If your app is using `AlarmManager`, it should not be allowed to be moved to external storage, for that very reason. Fortunately, moving to external storage is not relevant for most devices nowadays. – CommonsWare May 10 '14 at 10:41
  • I haven't checked it in logcat but I will. I think after android 3.1 there is no need to start app once. I will try to not allow it to external storage. Than you! – MCA Shah May 10 '14 at 13:36
  • It worked when I moved my app from SD card to phone. Thank you CommonsWare and all! – MCA Shah May 10 '14 at 18:39

2 Answers2

1

Some devices (mostly HTC) has a feature called fast reboot which doesn't trigger BOOT_COMPLETED. Instead they trigger QUICKBOOT_POWERON. So you need to register a recever for both broadcasts.

<action android:name="android.intent.action.QUICKBOOT_POWERON" />

Onur
  • 5,617
  • 3
  • 26
  • 35
  • 1
    It depends on what your app does. If it schedules alarms and wants to restore them on startup for example, the "fast reboot" will preserve the alarms too so you don't need to do anything on QUICKBOOT_POWERON. – BladeCoder May 10 '14 at 09:55
0

Thank you All for your giving your precious time!

As CommonsWare said in his comment, I moved it to the internal storage and the BOOT_COMPLETED receiver is working fine.

Thank you all once again!

MCA Shah
  • 405
  • 1
  • 4
  • 10