我想在应用程序中添加一项功能。我想关闭应用程序,而我点击退出按钮,但我的按钮是在对话框,所以当我尝试使用完成()是不会做同样的。我只想关闭应用程序,请帮助。对于同一无法关闭android中的对话框中的应用程序
if (v.getId() == R.id.imgLogout) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext());
alertDialog.setMessage("Are you sure you want to exit?");
alertDialog.setPositiveButton("YES", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// session.logoutUser();
finish();
}
});
//但完成
//代码没有在对话
为什么是U起动活动?你需要使用**完成()**关闭应用程序。 – Raghavendra
我没有看到你使用'finish()' –
[如何以编程方式退出android应用程序]的可能重复(https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically) – Raghavendra