我正在學習在android中開發,我需要您的幫助。 這是我用它來收我的應用程序...關閉應用程序並在啓動器上打開
boolean twice;
@Override
public void onBackPressed() {
if(twice) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
System.exit(0);
}
twice = true;
toastMessage(getResources().getString(R.string.msg0a));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
twice = false;
}
}, 2000);
}
問題是,當我回到我的應用程序在其最後一次活動開,我whant它LAUNCHER活動開放。
編輯:其原因是:我有一個活動,用戶可以從帳戶登錄和登錄活動的命運。註銷後,當用戶打開我的應用程序時,他必須一次又一次地通過登錄活動,而他不登錄。
只需調用finish(); inside onBackPressed() –
@ dcd4u2:你能告訴我們你是如何回到應用程序?通過應用程序圖標在家裏或最近的屏幕? – AndiGeeky
@AndiGeeky:是的,通過家裏的圖標。 – dcd4u2