Android Activity lifecycle and locking/unlocking device

孤人 提交于 2019-11-28 04:42:31

On phones (or tablets with the orientation locked portrait), the lock screen is portrait only. Therefore when the device is locked, the device automatically switches to portrait mode (causing 6, 7, 8, and 9). When the device is unlocked, then onResume() is called as your Activity is becoming visible, but you are again transitioning between portrait and now locked in landscape, so the Activity gets destroyed and recreated in landscape.

To over come of activity re-creation scenario, you can handle configuration changes at activity level by android manifest file using android:configChanges="orientation" attribute.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!