Try to put it in onStart() instead of onAttachedWindow()?