Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>It seems a bit crazy from a memory management point of view that each time you want to display a different form / page you need to use StartActivity which then creates a new instances of the class instead of reusing instances previously created.</p> </blockquote> <p>Tactically, you are welcome to add <code>FLAG_REORDER_TO_FRONT</code> to bring an existing activity back to the foreground, so long as you understand the ramifications from a navigation standpoint.</p> <p>However, your question is rather curious. How are you accessing StackOverflow?</p> <p>Clearly it's not via a Web browser. Web browsers use the exact mechanism that you feel is "crazy", rendering Web pages even if that Web page had been viewed previously. They have been doing so for over 15 years, and we've been doing OK by it.</p> <p>The Android navigation model is designed to approximately mirror that of the Web:</p> <ul> <li>Users click on things to move forward</li> <li>Users click on a BACK button to move to the previous thing they were looking at</li> <li>Users click on a HOME button when they want to switch to some other major thing to go look at</li> </ul> <p>By "reusing instances previously created", you're circumventing that navigational model. For example, let's suppose your activity stack were A-B-C-D, and you call <code>startActivity()</code> with an <code>Intent</code> for B and <code>FLAG_REORDER_TO_FRONT</code>. Now, the activity stack is A-C-D-B. When the user presses BACK times, they no longer are on the B they were looking at originally, but are back at A. In a browser, this would be rather strange behavior.</p> <p>There are other flags on <code>Intent</code>, or attributes on <code>&lt;activity&gt;</code> in the manifest, that offer "reusing instances previously created". However, they are not there "from a memory management point of view". They are there where the traditional Web BACK-heavy navigation pattern does not fit your needs.</p> <p>Assuming you aren't screwing up anywhere, Android will destroy under-utilized activities, garbage collect that memory, and even return that memory to the OS.</p>
 

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