我观察到某些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
?默认情况下我总是认为它是真的,但在文档中找不到它的任何参考。
答案 0 :(得分:0)
您是否检查过Android Activity生命周期?
https://developer.android.com/guide/components/activities/activity-lifecycle.html