Can an activity be killed with just onPause?

2019-04-13 03:28发布

This is what I read from a book:

The activity can be destroyed silently after onPause(). We should never assume that either onStop() or onDestroy() is called.

But according to the documentation, Pause refers to partly visible, can an activity partly visible be killed without calling onStop or onDestory?

2条回答
Fickle 薄情
2楼-- · 2019-04-13 04:04

There is no guarantee that onStop or onDestroy will be called. In situations when memory is severely lacking, the partially visible and out-of-focus Activity may be destroyed to reclaim resources. However, there is no guarantee that either of the two mentioned lifecycle methods will be called before doing so. This is why it is important to save persistent state in onPause instead of onStop and onDestroy.

查看更多
小情绪 Triste *
3楼-- · 2019-04-13 04:12

Refering to activity lifecycle - if activity is killed by system, it can be killed silently in Pause state within calling onStop or onDestroy.

查看更多
登录 后发表回答