Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Question 1: See <a href="http://developer.android.com/reference/android/app/Fragment.html#Lifecycle" rel="nofollow noreferrer">http://developer.android.com/reference/android/app/Fragment.html#Lifecycle</a>:</p> <blockquote> <blockquote> <p>"As a fragment is no longer being used, it goes through a reverse series of callbacks:</p> <p>onPause() - fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.</p> <p>onStop() - fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.</p> <p>onDestroyView() - allows the fragment to clean up resources associated with its View.</p> <p>onDestroy() - called to do final cleanup of the fragment's state.</p> <p>onDetach() - called immediately prior to the fragment no longer being associated with its activity."</p> </blockquote> </blockquote> <p>Question 2: If you must know that it was the back button <strong><em>specifically</em></strong> that is triggering the callbacks, You can capture the back button press in your Fragment's Activity and use your own method to handle it:</p> <pre><code>public class MyActivity extends Activity { //... //Defined in Activity class, so override @Override public void onBackPressed() { super.onBackPressed(); myFragment.onBackPressed(); } } public class MyFragment extends Fragment { //Your created method public void onBackPressed() { //Handle any cleanup you don't always want done in the normal lifecycle } } </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.
    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