Back button exiting application in android
I'm a bit puzzeled, I have an application which has 5 tabs in tabHost. Each tab has an activityGro开发者_JS百科up, which further has a parent and a child activity. The parent activity contains list of titles and the child activity has the details of those titles. Now, if I move on to another tab in my application from details page and then come back to the same tab in which i was viewing the details, the details are again displayed whereas the parent activity should be shown or if i press back button from here it exits my application whereas it should go to it's parent activity.
It is like
Tab1 - ActivityGroup Tab2 - ActivityGroup
ParentActivity1 - ListActivity ParentActivity2 - ListActivity
ChildActivity1 - Activity ChildActivity2 - Activity
Now when i go from ChildActivity1 to Tab2 - ParentActivity2 and come back to Tab1 i get to see the ChildActivity1 only and if i press back button then my application exits
Please help
Seems Your stack not managed properly or clearing up . check what stack option you are passing with intent for new activity .
You need to capture the back button, and bring up the activity you want. As far as the system is concerned, I think it treats your TabActivity as the only Activity to have BACK act upon.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
// goto parent screen
}
精彩评论