I have four actions in my tasks A, B, C, D.
Events are triggered in the order A-> B-> C-> D.
Here
I want to return to activity A from D and resume this activity.
So I used the flag of intent
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Actions B, C, D are no longer needed after stmt 1.
I go for the flag to accomplish this,
Intent.FLAG_ACTIVITY_CLEAR_TOP
In my application, using the above 1 and 2, I try to achieve, for example, go back and resume activity A and remove other actions from the stack
so i tried.
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
using the code above, both flags are added here using this link
( Android: what's the difference between setFlags and addFlags for intent )
I cannot complete this task together (resume action A and clear another).
actual call script
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).
So how can I combine these flags to get a combined action, to resume A and clear the others, or is there any other way to do this.
this is my manifest
<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" />
activity 1-> 2
Intent i = new Intent(getApplicationContext(), TopMenuBar.class); startActivity(i);
- You can complete this action in 1 second - repeat / cancel
activity 2-> 3
Intent i = new Intent(getApplicationContext(), Activity3.class); startActivity(i);
and 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);
Muthuraj
source share