onKeyDown / onBackPressed is not firing
In which cases are onKeyDown, onBackPressed not firing?
In my case I have a TabActivity with a ActivityGroup in background where all the upcoming views/activities are stored. The ActivityGroup takes care of adding and removing views. So when I start a new Activity in my main tab the startChildActivity method of ActivityGroup is called:
public void startChildActivity(String viewId, Intent intent) {
Window window = getLocalActivityManager().startActivity(viewId, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if(window != null) {
history.add(new HistoryContainer(viewId));
setContentView(window.getDecorView());
}
}
If I now start the Activity Dummy in this way the mentioned keyEvents like onKeyDown or onBac开发者_C百科kPressed are not firing anymore. What's happening is the app is closing.
public class Dummy extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dummy);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
MazdaGroup.group.back();
return true;
}
@Override
public void onBackPressed() {
MazdaGroup.group.back();
}
}
Would be glad for your help!
精彩评论