views:

110

answers:

1

Hello everybody, I have a question on the Android Activity, for example I have a TabHost, and there are included four Activities, the first tab is a search Activity, enter a keyword in the current result of this Activity to return, and in the current Activity display. Is called to display the search results themselves. And after searching several times, and then return to key mobile phone keypad, the display is the result of the last search keyword, I want the press back key to return to the last call of the Activity or TabHost. Should I do?

By the way, in a tab in the use of Intent calls a Activity,

eg: host.addTab (host.newTabSpec ("friend"). setIndicator ("search") . SetContent (new Intent (this, Search.class)));

In this Activity in the need to call another Activity,

e.g: startActivity (new Intent (this, Other.class));

Also called another Activity displayed on this tab, but not yet jump out of the show. I ask how you can achieve this?

A: 

First, you can use startActivityForResult(...) instead of startActivity(...). This means that when you're done with the activity, you want to come back to the activity that started it so you can do more.

Second, you can override the onKeyDown(...) method and define whatever behavior you want for the back key. however, this is not recommended by Google except when absolutely necessary.

mtmurdock