简体   繁体   中英

Android Activity Lifecycle With/Without Lock-screen

I'm trying to find out what the difference is in the activity lifecycle when a lock-screen is enabled versus disabled.

Scenario A (no lock-screen)

  • App is running
  • power button is hit to turn display off
  • power button is hit to turn display on
  • App is immediately resumed

Scenario B (lock screen enabled, swipe to unlock)

  • App is running
  • power button is hit to turn display off
  • power button is hit to turn display on
  • Swipe screen to unlock
  • App is resumed (but we are getting a bug in the display, which is where we are trying to find the difference)

I have printed out the activity lifecycle for both scenarios and they show up identical for both scenarios.

What might be the difference in the lifecycle that would cause this different behavior when using lock-screen versus no lock-screen?

Take a look at this documentation . It could be that the lock screen would imply that the app process is killed and therefore data is lost (which is necessary to present the page and therefore the app crashes). I would suggest to debug the activity states to find the answer you're looking for.

You can test it with writing Logs into onResume(), onCreate(), onPause(), onDestroy() etc.

Also pressing Power button and and opening LockScreen changes the devices screen orientation into "Portrait" mode(Phones and tablets with locked rotation only). It may cause different reactions you are mentioned about.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM