onStop vs onDestroy

前端 未结 2 926
情深已故
情深已故 2021-02-20 01:26

I have tried to research exactly when the onDestroy method is called for an activity, but I\'ve read some confusing and conflicting information. In general, my question is: unde

2条回答
  •  失恋的感觉
    2021-02-20 02:22

    Like stated in the official documentation:

    onDestroy()
    

    The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.

    In your example the Activity A is stopped and could be destroyed by the System


    Note per documentation link above:

    …do not count on [onDestroy()] being called as a place for saving data … [see] either onPause() or onSaveInstanceState(Bundle).

提交回复
热议问题