Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure which emulator you are testing with, but <code>onPause</code> is the one method that is <em>always</em> guaranteed to be called when your <code>Activity</code> loses focus (and I say <em>always</em> because on some devices, specifically those running Android 3.2+, <code>onStop</code> is not always guaranteed to be called before the <code>Activity</code> is destroyed).</p> <p>A nice way to understand the <code>Activity</code> lifecycle for beginners is to litter your overriden methods with <code>Log</code>s. For example:</p> <pre><code>public class SampleActivity extends Activity { /** * A string constant to use in calls to the "log" methods. Its * value is often given by the name of the class, as this will * allow you to easily determine where log methods are coming * from when you analyze your logcat output. */ private static final String TAG = "SampleActivity"; /** * Toggle this boolean constant's value to turn on/off logging * within the class. */ private static final boolean VERBOSE = true; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (VERBOSE) Log.v(TAG, "+++ ON CREATE +++"); } @Override public void onStart() { super.onStart(); if (VERBOSE) Log.v(TAG, "++ ON START ++"); } @Override public void onResume() { super.onResume(); if (VERBOSE) Log.v(TAG, "+ ON RESUME +"); } @Override public void onPause() { super.onPause(); if (VERBOSE) Log.v(TAG, "- ON PAUSE -"); } @Override public void onStop() { super.onStop(); if (VERBOSE) Log.v(TAG, "-- ON STOP --"); } @Override public void onDestroy() { super.onDestroy(); if (VERBOSE) Log.v(TAG, "- ON DESTROY -"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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