Domanda

I implemented TabActivity in my android application. On first time I load activity and click on 2nd tab to load Activity say activity2 on second tab => in second tab I have grid view=> on click event of grid view I open the child activity23 on second tab by using code bellow:

Intent intent=new Intent(activity2.this, activity23.class);

TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("activity23", intent);

when I come back(finish) from activity23 to activity2 and again I click on grideview to go activity23 then it not start child activity. I tested various devise it work all devise fine except the android2.3.3. This problem occur only in 2.3.3 and 2.3.6 devise according to my testing.

After debugging I found that The function of TabGroupActivity=> StartChildActivity() like below

public void startChildActivity(String Id, Intent intent) {     

Window window = etLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)); if (window != null) { mIdList.add(Id); setContentView(window.getDecorView()); }
}

here at first time window object get not null in android os 2.3.3 but if we finish the child and again start same child to start then window object become null so it is not load child activity.

if any one have any idea to resolve this problem then most welcome if any one have complete code for tabView for all android devise above 2.2 then most welcome.

È stato utile?

Soluzione

I solve this problem passing random number as unique id when I start child activity in TabGroupActivity below is the code for solution

Intent intent=new Intent(activity2.this,activity23.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity((new Random().nextInt(90)+11)+"", intent);

We have to pass unique each time when we create new intent to push on tab.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top