I have a main Activity A, in which I create a background thread to load data from db. After the loading is done, I want to update the list which might have been already shown in a child activity B (If user has navigated to B in the meanwhile). If user hasnt yet navigated to B, its not an issue.
But how to update B’s list once thread in A has finished?
B is a child of A.
Thanks,
Thanks Imran,
I handled it by creating an IntentService in a separate class (inner class was not working), and start it from A. After work is done I fire a BroadCast from the IntentService which B’s broadcastreceiver is listening. It updates the list eventually.
Here is the code:
In class A, just start the IntentService in for ex OnCreate():
Create IntentService like (in a separate class):
In class B I create an inner class which just updates the list like:
In B, dont forget to register the receiver. In B’s onCreate() method:
And the usual service tag in AndroidManifest.xml