Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to launch Activity with FLAG_REORDER_TO_FRONT and FLAG_CLEAR_TOP
    primarykey
    data
    text
    <p>I have four activity in my tasks A,B,C,D. </p> <p>Activities are launched in order A->B->C->D. </p> <p>Here, </p> <ol> <li><p>I want to go back to the activity A from D and resume that activity .<br> So that i used the intent flag </p> <pre><code>i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); </code></pre></li> <li><p>Activities B,C,D instance are is no longer needed after the stmt 1.<br> i go for the flag to accomplish this, </p> <pre><code>Intent.FLAG_ACTIVITY_CLEAR_TOP </code></pre></li> </ol> <p>In my appp using the above 1 and 2 i try to achieve like<br> - go back and resume the acivity A and remove the other activities from the stack<br> so i tried like. </p> <pre><code> i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //vise versa </code></pre> <p>using the above code both flags are appened here using this reference<br> (<a href="https://stackoverflow.com/questions/6664189/androidwhat-is-difference-between-setflags-and-addflags-for-intent">Android:What is difference between setFlags and addFlags for intent</a>)</p> <p>I am not able to achieve these task combined( resume the activity A and clear other). </p> <p>actual calling scenario is </p> <pre><code>when i use the CLEAR flag the call is like D-&gt;oncreate(A) and clear BCD when i use the REORDER flag the call is like D-&gt;onrestart(A). </code></pre> <p>So how can i combine this flags to get the combined action to resume A and clear other or is there any other way to do this. </p> <p>this is my manifest</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tpv.vptest" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".NeverStopActivity" android:label="@string/title_activity_main" android:launchMode="singleInstance"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; </code></pre> <p>activity 1->2</p> <pre><code>Intent i = new Intent(getApplicationContext(), TopMenuBar.class); startActivity(i); </code></pre> <ul> <li>You can perform this action again in 1 seconds - retry / cancel</li> </ul> <p>activity 2->3</p> <pre><code>Intent i = new Intent(getApplicationContext(), Activity3.class); startActivity(i); </code></pre> <p>and 3-> 1</p> <pre><code>Intent i = new Intent(getApplicationContext(), NeverStopActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(i); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload