タスクA、B、C、Dに4つのアクティビティがあります。
アクティビティは、A-> B->C->Dの順に開始されます。
ここ、
DからアクティビティAに戻り、そのアクティビティを再開したいと思います。
インテントフラグを使用したようにi.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
stmt 1の後、アクティビティB、C、Dインスタンスは不要になりました。
これを達成するためにフラグを使用し ます。Intent.FLAG_ACTIVITY_CLEAR_TOP
上記の1と2を使用した私のアプリでは、次のように達成しようとしてい
ます-戻ってアクティビティAを再開し、スタックから他のアクティビティを削除して、次の
ように試しました。
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //vise versa
上記のコードを使用すると、このリファレンスを使用して両方のフラグがここに追加されます
(Android:意図のsetFlagsとaddFlagsの違いは何ですか)
これらのタスクを組み合わせて達成することはできません(アクティビティAを再開し、その他をクリアします)。
実際の呼び出しシナリオは
when i use the CLEAR flag the call is like D->oncreate(A) and clear BCD
when i use the REORDER flag the call is like D->onrestart(A).
では、このフラグを組み合わせて、Aを再開し、他をクリアするための組み合わせアクションを取得するにはどうすればよいですか、またはこれを行う他の方法はありますか?
これは私のマニフェストです
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tpv.vptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".NeverStopActivity"
android:label="@string/title_activity_main"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
アクティビティ1->2
Intent i = new Intent(getApplicationContext(), TopMenuBar.class);
startActivity(i);
- このアクションは1秒後に再度実行できます-再試行/キャンセル
アクティビティ2->3
Intent i = new Intent(getApplicationContext(),
Activity3.class);
startActivity(i);
および3->1
Intent i = new Intent(getApplicationContext(),
NeverStopActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);