嗨,我们正在使用 phone-gap 开发 android 平板电脑,现在我必须在控制后退按钮的同时使用后退按钮,如果我们单击后退按钮,它必须提醒我们正在使用此代码注销应用程序
public class MainActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setIntegerProperty("loadUrlTimeoutValue", 120000);
super.loadUrl("file:///android_asset/www/Common/login.html");
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
alertbox.setIcon(R.drawable.ic_launcher);
alertbox.setTitle("Are you sure..! You want to exit?");
alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
finish();
}
});
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
}
});
alertbox.show();
}
return super.onKeyDown(keyCode, event);
}
}
return super.onKeyDown(keyCode, event);
}
问题是,如果我们点击后退按钮,它会显示是或否的警报,但在选择是或否选项之前,它正在导航到后页,我们必须停在那里,直到我们选择是或否,你能建议我任何变化。