![](/img/trans.png)
[英]How do I use back stack or get getChildFragmentManager() with this specific pager adapter in order to use the back button?
[英]How should I use the Back Stack to allow usage of the back button?
所以,我有這個應用程序有4種不同的活動:
我想要做的是大多數應用程序的標准行為。 那是:
我的應用正確執行了第1點和第2點,但是在第3點上,該應用消失了。
按鈕的onClick方法具有以下內容:
startActivity(new Intent(this,C.class));
沒有活動覆蓋onBackPressed方法。
這是我的清單文件(的一部分):
<activity android:name=".A" android:label="A" android:launchMode="standard" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".B" android:label="B" android:launchMode="standard" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait"/>
<activity android:name=".C" android:label="C" android:launchMode="standard" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait"/>
<activity android:name=".D" android:label="D" android:launchMode="standard" android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait"/>
我從完成的調試工作中知道,在調用按鈕的onClick方法之后,將調用A.onDestroy()。 基於此信息,我認為,當然我可能是錯的,由於某種原因,操作系統從歷史記錄堆棧中刪除了活動A。
現在,我知道這里已經在stackoverflow上解決了此類問題,但是我嘗試了所有可以發現的建議,但都沒有奏效。 我想解釋我自己的情況。
當然,我應該做錯了。
我覆蓋了onWindowFocusChanged方法並銷毀了那里的活動,因此,當然將其從堆棧中刪除了。
很抱歉浪費您的時間@stefan和@colegu。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.