Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want your application to react this way, you should declare the launch mode of your activity A as:</p> <pre><code>android:launchMode="singleTop" </code></pre> <p>in your AndroidManifest.xml.</p> <p>Otherwise android uses standard launch mode, which means </p> <blockquote> <p>"The system always creates a new instance of the activity in the target task"</p> </blockquote> <p>and your activity is recreated (see <a href="http://developer.android.com/guide/topics/manifest/activity-element.html#lmode" rel="noreferrer">Android documentation</a>).</p> <p>With singleTop the system returns to your existing activity (with the original extra), if it is on the top of the back stack of the task. There is no need to implement onSaveInstanceState in this situation. </p> <p>savedInstanceState is null in your case, because your activity was not previously being shut down by the OS.</p> <p><strong>Notice</strong> (thanks, android developer for pointing to <a href="https://stackoverflow.com/a/20306670/2306907">this</a>)<strong>:</strong></p> <p>While this is a solution to the question, it will not work if the activity one returns to is <em>not</em> on the top of the back stack. Consider the case of activity A starting B, which is starting C, and C's parent activity is configured to be A. If you call <code>NavigateUpFromSameTask()</code> from C, the activity will be recreated, because A is not on top of the stack.</p> <p>In this case one can use this piece of code instead:</p> <pre><code>Intent intent = NavUtils.getParentActivityIntent(this); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP); NavUtils.navigateUpTo(this, intent); </code></pre>
 

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