I believe that onAttachedToWindow()
is called when the onCreate()
's setContentView(R.layout.myLayout.xml)
is called. So can I assume then that in the activity lifecycle that onDetachedFromWindow()
is called when the activity is destroyed? My question is how do I tie these two call back hooks to the activities lifecycle?
Can I say that onAttachedToWindow()
is tied to onCreate()
and onDetachedFromWindow()
is tied to onDestroy()
?
onPause() Called when the system is about to start resuming a previous activity. There are two possible lifecycle methods that will be called after OnPause() : OnResume() will be called if the Activity is to be returned to the foreground.
Note that onSaveInstanceState() is called when your activity goes into the background and NOT when the app process is about to be killed.
onPause. Called when the Activity is still partially visible, but the user is probably navigating away from your Activity entirely (in which case onStop will be called next). For example, when the user taps the Home button, the system calls onPause and onStop in quick succession on your Activity .
If a dialog is opened on the activity then the activity goes to pause state and calls onPause() method.
Technically speaking onAttachedToWindow
is called after onResume
(and it happens only once perlifecycle).
ActivityThread.handleResumeActivity
call will add DecorView
to the current WindowManger
which will in turn call WindowManagerGlobal.addView()
which than traverse all the views and call onAttachedToWindow
on each view.
onDetachedFromWindow
is tied with onDestroy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With