简体   繁体   English

后退按钮不起作用

[英]Back button doesn't work

I have an application with two activities. 我有两个活动的应用程序。 In the first activity it is possible to start the second by clicking a button. 在第一个活动中,可以通过单击按钮开始第二个活动。

@Override
public void onClick(View v) {
    Intent intent = new Intent(firstActivity, SecondAcitivity.class);
    startActivity(intent);
}

Bizarrely, clicking the back button in the second activity doesn't bring me back. 奇怪的是,单击第二个活动中的后退按钮不会让我回头。 I thought such basic behavior is already implemented so that I don't have to do anything about it. 我认为这种基本行为已经实现,所以我不必对此做任何事情。 Actually in other apps I wrote there never has arisen such a problem. 实际上在我写的其他应用程序中从来没有出现过这样的问题。

Of course in the class of the first activity I have 当然,在我的第一项活动的课上

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...
    firstActivity = this;
    ...
}

Have you done something to intercept the key event? 你有没有做过拦截关键事件的事情?

For example: 例如:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
    return true;
}
return super.onKeyDown(keyCode, event);
}

or 要么

@Override
public void onBackPressed() {
//not invoke the super.onBackPressed();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM