I believe it is possible that onAttachedToWindow will be called when setContentView called.
When you use split screen on Android N and the configChanges activity value in AndroidManifest.xml should be set:
"keyboardHidden|orientation|screenSize"
onAttachedToWindow will be called in setContentView because the "mAttachInfo" variable in the window decor is not null when you call setContentView to add a rootView in the decorView , dispatchAttachedToWindow called in addViewInner() .
Finally, after the onResume() action, onAttachedToWindow() will not be called again.
source share