I need to start a notification service for an application when the device boots. I have implemented a BroadcastReceiver
that listens to the boot signal in order to start the service.
However, this works only if the application is not installed on sdcard (because the signal is received before the sdcard is mounted). Is there any solution to keep installing the application on sdcard and yet still receive that signal?
Any hack for this?
Let me know!
Thanks!
You could either:
- Register an account in the
AccountManager
and set up a sync service (tutorial1, tutorial2) -- Android will start your service automatically; or
- Listen for some other broadcasts as well (such as screen off / screen on) and test whether you need to start your notification service or not.
I realize these are not easy / convenient solutions, but they're the only ones I can think of. If anyone knows a better solution, I'll be happy to upvote :).
Another solution (which could eventually be used in conjunction with one of the above) is to start your service (or check if it needs to be started) when your application is launched from the application launcher (i.e. when the "main" activity is started).