当configChanges当configChanges最近在做一个ProgressDialog对话框,遇到锁屏解屏时,出现View not attached to window manager和Window Leaked问题,最后发现是由于manifest.xm文件中的configChanges导致的。
1.当设置configChanges
android:configChanges="orientation|screenSize" 执行onPause()--onSaveInstanceState()--onStop()--onRestart()--onStart()--onResume()
2.当不设置configChanges
2.1 锁屏
onPause()--onStop()--onDestory()--onCreate()--onStart()--onResume()--onPause()
2.2 解屏 onResume()--onPause()--onStop()--onDestory()--onCreate()--onStart()--onResume()
由于configChanges没有设置,导致重新建Activity,ProgressDialog无法依附原来Activity,此时需要调用onDestory()执行dismiss操作。