所以我想使用onBackPressed作为选项,在点击时返回主要活动,但是,我当前的设置只是让它关闭应用程序。任何帮助将不胜感激,谢谢!
if (id == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
答案 0 :(得分:1)
您可以使用onBackPressed()
:
@Override
public void onBackPressed() {
Log.d("CDA", "onBackPressed Called");
//call you activity here.
}
或者onKeyDown(int keyCode, KeyEvent event)
:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
//call you activity here.
}
return super.onKeyDown(keyCode, event);
}