Record the life cycle changes of the activities of mobile phones above Android 7.0 after opening the split screen

Record the life cycle changes of the activities of mobile phones above Android 7.0 after opening the split screen

The address of this article: https://blog.csdn.net/qq_40785165/article/details/112565073 , reprinted need to attach this link
(1) Huawei mobile phone split screen test (Android10) to
run an App, take MainActivity as an example
1. Open the App Time life cycle
Screenshot

onCreate->onStart->onResume

2. Life cycle when opening the task list
Screenshot

onPause->onStop

3. Life cycle after split screen in task list
Screenshot

onDestroy->onCreate->onStart->onResume->onPause->onResume
这里我手机的分屏会自动获取焦点,没有焦点的只会走到onPause,需要自己手动点击activity获取焦点
所以一些播放视频或者动画效果的功能,暂停的功能代码就不能放在onPause里了,应该放在onStop里

4. Cancel the life cycle of split screen
Screenshot

onPause->onStop->onDestroy->onCreate->onStart->onResume

5. Life cycle of mobile split screen
Screenshot

onPause->onStop->onDestroy->onCreate->onStart->onResume

(2). Xiaomi mobile phone split screen test (Android10)
1. Life cycle when opening the App
Screenshot

onCreate->onStart->onResume

2. Life cycle when opening the task list
Screenshot

onPause->onStop

3. Life cycle when split screen
Screenshot

onDestroy->onCreate->onStart->onResume

4. Life cycle when back to the desktop

onPause

5. Back to the life cycle of split screen

onResume

6. Life cycle of mobile split screen
Screenshot

onPause->onStop->onDestroy->onCreate->onStart->onResume

7. Life cycle when exiting split screen
Screenshot

onPause->onStop->onDestroy->onCreate->onStart->onResume

Note:

因为分屏的时候会重新走生命周期,对于fragment尽量使用replace而不是add,数据请求也会多调用几次,
要是介意的同学也可以使用下面的代码在AndroidManifest.xml中配置禁用分屏,分屏的时候系统会有不支持分屏的提示
android:resizeableActivity="false"

The above is the life cycle test of the split screen of the two mobile phones. Record it and pay more attention when writing the logic in the future. Other mobile phones cannot be tested due to conditions. If there is any difference, please feel free to advise me in the comments section below. Everyone makes progress together!

Guess you like

Origin blog.csdn.net/qq_40785165/article/details/112565073