Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As a general advice: <strong>Don't exploit the OS.</strong></p> <p>Other then in regular desktop systems, Android (and iOS) are systems where you normally don't have <em>that</em> many applications you commonly use. Since most users only use a hand full of applications very often, the system does not completely "kill" the app when you return to the home-screen, to make it load up faster when it is opened <em>again</em>.</p> <p>This will result in a few applications starting very fast (the most commonly used ones). But, when the Android system needs the occupied resources, it will free those by itself, killing off some older applications which are still running in the background.</p> <p>That's why you normally shouldn't terminate an application yourself.</p> <hr> <p>Apart from the above statement, it seems that you're trying to manually launch the home-screen. <strong>There is no need to do that!</strong></p> <p>If you simply want to add an option which returns from your application back to the home-screen, call <a href="http://developer.android.com/reference/android/app/Activity.html#finish%28%29" rel="nofollow"><code>this.finish()</code></a> in your <code>Activity</code>. This will then close the current Activity and return to the home screen.</p> <hr> <p>As the last point, if you want your application to <strong>store information about the current state</strong> (like it seems you're doing using the Shared Preferences), you should do this in your Activity's <a href="http://developer.android.com/reference/android/app/Activity.html#onStop%28%29" rel="nofollow"><code>onStop()</code>-method</a> or <code>onPause()</code>-method. See the <a href="http://developer.android.com/reference/android/app/Activity.html#SavingPersistentState" rel="nofollow">Docs for more information</a>.</p> <p>This method will be called by the Android system, regardless if you close your application yourself or the system closes it (because it needs memory space).</p> <hr> <p>And last (and least), some <strong>general Android programming advices</strong>:</p> <p>Don't manually create activity's with the <code>new</code>-operator. Let the system do it and use <code>Intent</code>s for that purpose.</p> <p>Activity's are really just "walls to paint on". They are meant to <em>show</em> something to the user. Application code (and any kind of heavy lifting) should almost always be put into an <code>AsyncTask</code>. This way, your UI will always respond and never "freeze", which will make users nervous.</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