[英]Android issue while exit my application
對不起,如果已經回答了,我搜索並沒有找到(可能是我的關鍵詞錯誤),因為我找到了解釋說明如何強制退出應用程序或退出所有活動,...但這不是我的問題。 我的應用程序退出良好。
退出應用程序時遇到一個奇怪的問題。 重現我的問題的步驟(而且每次我都執行以下步驟):
我啟動一個應用程序X,例如游戲,Android參數,“ hello world”默認應用程序,...
我按HOME鍵
現在,我從應用程序列表中啟動我的應用程序
我按回退出我的申請
我的申請退出
在(1)中啟動的應用程序自動啟動,而不是返回首頁
有關信息:我使用捕獲返回鍵退出我的應用程序,詢問用戶是否真的要退出,如果他說是,我打電話給finish()
--EDIT 1開始-我可以分享一些代碼作為finish方法(在Activity中):
private void reallyExitTheApplication()
{
if(this.serviceLink!=null)
{
this.unbind(this.serviceConnection);
this.serviceLink = null;
}
this.finish();
}
和調用它的代碼
public void onClick(View view)
{
switch(view.getId())
{
// ...
case R.id.buttonValidateExit :
this.reallyExitTheApplication();
break;
// ...
}
}
-編輯1結束-
-編輯2開始-
我還為我的Activity添加清單部分:
<activity
android:name="jhelp.tests.browser.BrowserManagerActivity"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize"
android:label="@string/browserName"
android:launchMode="singleInstance"
android:taskAffinity="jhelp.tests.browser">
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="org.mozilla.gecko.LOAD"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"/>
</intent-filter>
</activity>
-編輯2結束-
知道Android為什么決定啟動應用程序(1)而不返回家嗎?
以前,我已經建立了很多應用程序,這是我第一次看到它。
謝謝你的幫助
JHelp
您打開的第一個應用程序在屏幕上顯示了SplashScreen。
您按下了主頁按鈕,同時啟動了您的應用程序,與此同時,第一個應用程序的mainActivity又添加到了應用程序2的后面(就像兩個活動一個接一個),因此當您按回應用程序的第一個主要活動時,您會看到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.