2

I have followed this tutorial for my application.

I have: Tab 1: Tabgroupactivity1>(startchildactivity)MainActivty>(startchildactivity)ListActivity>(startchildactivity)DetailActivity

similarly I have other two tabs.

The thing is that when i Return from any of the following activity to previous one it(previous one) gets restarted.

I too have tried to startchild activity with SINGLE_TOP and SINGLE_TASK but in this only once I can go through the flow

second time it does not call following(next/child) activity

So How can i maintain current activty state while it calls for child activity and return ??

I am Using following intent onclick of listactivty:

Intent myintent = new Intent(getParent(),Second.class);
myintent.putExtra("id",favadapter.getItem(position).id.toString());
TabGroupActivity parentFav = (TabGroupActivity)getParent();
parentFav.startChildActivity("FavActivity", myintent);
Hanry
  • 5,481
  • 2
  • 40
  • 53

1 Answers1

2

Actually TabGroupActivity have a problem in android 2.1 and 2.2 , the activities not properly removed from stack causes our instance to restart every time.

To overcome that issue we use SINGLE_TOP and SINGLE_TASK, even it cause another problem only one instance run not for second time because in child finish we did like this,

Intent lastIntent = manager.getActivity(lastId).getIntent();
        Window newWindow = manager.startActivity(lastId, lastIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP));
        setContentView(newWindow.getDecorView());

means it remove all lastID intent and bring the latest one, because your lastId (which is used while starting activity .startChildActivity("FavActivity", myintent); ) is same for multiple instance.

In order to allow your child activity to run second time or for multiple instance use Dynamic intent ID to launch child activity.

For example,

Intent myintent = new Intent(getParent(),Second.class);
myintent.putExtra("id",favadapter.getItem(position).id.toString());
TabGroupActivity parentFav = (TabGroupActivity)getParent();
parentFav.startChildActivity("FavActivity"+System.currentTimemillis(), myintent);
Karthi
  • 13,624
  • 10
  • 53
  • 76
  • I have used this issue exactly a month before: String newId = Id+""+Math.random()*1000; Window window = getLocalActivityManager().startActivity(newId,intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)); sometimes this too gives me blank screens for large stacks.:( – Hanry Mar 22 '12 at 13:37