I’m developing an Android application. This app consists of two activity.
- Main activity
- Secondary activity (called from Main Activity)
I have a thread that using the handler mechanism passes a messagge to Main Activity, and this activity showes an image.
I wish this icon was shown in both Activity. But if I’m sure that the Main activity is yet created, I can’t say the same for Secondary Activity. So, what happens if I try to send message from thread to an Activity that isn’t yet created?
Only one Activity can be active at a time, so you need to save the common data in some type of data storage (like a SharedPreference), or you can use global variables, or you can pass this information back and forth in Intents.
Whichever method you choose, it needs to be available whenever the next Activity starts. I suggest SharedPreferences since they are relatively simple and are not deleted when the app closes.