我想在應用程序中添加一項功能。我想關閉應用程序,而我點擊退出按鈕,但我的按鈕是在對話框,所以當我嘗試使用完成()是不會做同樣的。我只想關閉應用程序,請幫助。對於同一無法關閉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