Issue
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()
?
Solution
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
Answered By - WenChao
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.