0

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)?

Kevin Suppan
  • 232
  • 2
  • 18

2 Answers2

1

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

Joelmob
  • 1,076
  • 2
  • 10
  • 22
  • I was hoping for a onContextChange or something like that, but I guess onResume will do the trick for now. Thanks a bunch :) – Kevin Suppan May 19 '12 at 19:19
0

Each Activitys in Tab has its context. You can put extra/ get Extra as normal.

Another ways are:

Make public static variable. Preference.

Store it in SQLite.

Tai Tran
  • 1,406
  • 3
  • 15
  • 27
  • Yes I know this solution, as I mentioned in my question. But I want to inform the second Activity that it got something right now, an event or callback or smthn. Or do I really have to make a timer and check via getExtra if it's null or not? – Kevin Suppan May 19 '12 at 17:42
  • your question is the same as http://stackoverflow.com/questions/10665106/android-best-practice-approach-for-refreshing-page-data-at-a-certain-interval/10665878#10665878 But it 's still no solution. – Tai Tran May 19 '12 at 23:08