I have a very common problem but wasn't able to find a proper solution/pattern to solve it. My application has two kinds of data that need to be automatically updated:
If the user is not logged in, only general data are downloaded and displayed, if the user is logged in, his/her data are handled too.
I need to periodically download these data from a Web service, starting from the boot of the device (after the action android.intent.action.BOOT_COMPLETED
is triggered).
Since my app can be moved to the SD, I will also need to register for the android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE
action.
Issue 1: starting from API level 11 (Honeycomb) all actions aren't sent to applications in a stopped state. I haven't quite understood this, does this mean that my app can't listen for actions if it has just been installed and never opened (so only once if we count updates out)? Or does this mean that, after every system reboot, the action will be triggered only when the application starts?
Issue 2: if the application has been moved to SD, SyncAdapter
s won't be able to be run, so I have to rely on the general BroadcastReceiver
-Service
-Alarm
-PendingIntent
strategy. But how can I understand if the SyncAdapter
won't be started by the system? (I already handle Account
s by the AccountManager
)
Do you know of any library that takes care of all of this? It seems quite strange, isn't this a common issue?
Re: issue 1, as far as I can tell, an app is not "alive" until the user explicitly runs it for the first time. It will then still be "alive" until the end of the days, unless the user explicitly stops it using the Force stop button in Android's Applications management settings. He will then have to re-run manually the app for it to be able to receive broadcasts and stuff.