Search code examples
androidandroid-activityandroid-tabactivity

Pass data with event between Activities in Tabs - Android


I have a TabActivity with 4 Tabs (Activities) in it. Now I want to pass data between these 4 Tabs. I know how to pass it to the parent (TabActivity), but how do I pass it to one of the running Tabs' Activities? With putExtra I can pass it some data, but how do I know in the other Activity that it got data (something like an Event/Callback/whatever)?


Solution

  • You check if the data is in the intent with getExtra. I would solve this with public static variables. The simply get the reference to the Object from onResume in your activity. Remember to check that it's null