在同一个Activity中,onResume可以被调用两次而没有onPause吗?

时间:2017-11-16 23:26:21

标签: android android-activity

我观察到某些Android设备(Galaxy S8,LG,Motorola)onResume连续两次被调用,中间没有onPause。这种模式发生在onNewIntent之后。以下是虚拟应用程序中的日志序列:

Step 1. User starts the app
11-08 09:25:58.708 [MyActivity, hashcode - 126479478] onCreate
11-08 09:25:58.896 [MyActivity, hashcode - 126479478] onStart
11-08 09:25:58.971 [MyActivity, hashcode - 126479478] onResume

Step 2. User goes to background
11-08 09:26:04.949 [MyActivity, hashcode - 126479478] onPause
11-08 09:26:05.830 [MyActivity, hashcode - 126479478] onStop

Step 3. User comes back to the app
11-08 09:26:49.470 [MyActivity, hashcode - 126479478] onNewIntent
11-08 09:26:49.507 [MyActivity, hashcode - 126479478] onStart
11-08 09:26:49.530 [MyActivity, hashcode - 126479478] onResume

Step 4: We get second on resume
11-08 09:26:55.088 [MyActivity, hashcode - 126479478] onResume

在每个onPause之后,如果操作系统强行没有杀死该应用,Android Framework是否会保证onResume?默认情况下我总是认为它是真的,但在文档中找不到它的任何参考。

1 个答案:

答案 0 :(得分:0)