之前看Activity的生命周期一直没有今天细致,在我深入学习onSaveInstanceState(Bundle)方法的时候发现了一个好玩的选项:Don't keep activities选项
以前一直没有发现这个选项,这个选项用户是可以设置勾选的。
那怎么样找到这个神奇的设置呢?follow me
以我的三星盖5为例:
Settings--->Developer Options--->Don't keep activities勾选上
这样当你在按下Android手机Home键的时候,Activity的生命周期就不是像之前那样处于OnStop状态了,它会进入OnDestroy状态被系统销毁回收掉。
注意:所以希望大家记住这个选项,避免在开发中排查问题时,浪费一些时间。
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.