Reputation: 10437
I've an app where I wish to update the Activity (List activity to be precise) only when the activity from Service is in foreground (Active)
I can use ListActivity Intent but the problem is this brings up activity even when its in background.
I also considered using registerDataSetObserver on ListAdapter but that mandates that cursor should be updated. Updating the Cursor from external service may not be feasible.
Do we have a generic solution to this ?
Upvotes: 10
Views: 10119
Reputation: 795
The best solution is to have a centralized place. I consider this to be the best solution. Check this out:
Upvotes: 0
Reputation: 1006734
Do we have a generic solution to this ?
Probably a dozen of them. Here are a few:
onResume()
and remove it in onPause()
registerReceiver()
when it is in the foregroundPendingIntent
to the serviceResultReceiver
ContentProvider
, with the activity holding onto a Cursor
from the provider, and the service updating the providerThis set of projects demonstrates the first three, in the context of remote services.
Upvotes: 20