My Android app uses its Application class (to be precise its Application subclass) to run a thread to retrieve data from a website. Once it does it successfully it is supposed to give this data to the running Activity (there are 2 activities in my app). How could I notify the Activity about this? How can I tell the current Activity that there is new available data that should be retrieved and presented?
Thanks for your answers.
My Android app uses its Application class (to be precise its Application subclass) to
Share
What about using a broadcast system.
You can get the context in the Application class by using
getApplicationContext();Then you can send your own custom broadcast:
Then you can implement broadcast receiver in your activity’s to receive the broadcast.
More info here: http://thinkandroid.wordpress.com/2010/02/02/custom-intents-and-broadcasting-with-receivers/
You can set the data that you want to send in the Intent by using putExtra.
But you can also store it in a database and by using the broadcasts you let the activity know that there is new data available