I\'m not very clear about the Intent object and how to use it to pass data between Activities. In my application I have several tabs between which I want to pass ArrayList.
With the examples above, it was really work when I replace the "onStop" = "onPause"
/** Called when the activity looses focus **/
@Override public void onStop()
{
Intent myIntent = new Intent();
myIntent.putStringArrayListExtra("arrayPeople", arrayPeople);
this.setIntent(myIntent);
}
/** Called when the activity looses focus **/
@Override public void onPause()
{
Intent myIntent = new Intent();
myIntent.putStringArrayListExtra("arrayPeople", arrayPeople);
this.setIntent(myIntent);
}
I don't think altering the intent in onStop() will work because the TabHost handles the intents. Setting one class' intent with this.setIntent() wont let another class access it with getIntent() as they are built on different intents.
I would either store my arrayPeople in a database or I would pass arrayPeople back to the TabHost with MyTabs.setArrayPeople or something similar. Then you can query the db onCreate of your next tab or just pull it from your MyTabs Class.
What's about setting a static field into the myTabs object?
public class myTabs extends TabActivity {
....
public static arrayPeople = new ArrayList<String>();
....
On TabOne.java:
@Override
public void onStop(){
myTabs.arrayPeople = arrayPeople;
}
On TabTwo.java:
arrayPeople = myTabs.arrayPeople
Does make sense?