android 返回键 事件

//startActivityForResult()情况的Intent
@Override
public boolean onKeyDown(int i, KeyEvent event) {

// only intercept back button press
if (i == KeyEvent.KEYCODE_BACK) {
Bundle bundle = new Bundle();

bundle.putString("returnStatus", "CANCEL");
Intent mIntent = new Intent();
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}

return false;
}
//非startActivityForResult().
if里面直接finish()掉.

你可能感兴趣的:(android)