1

A. Simple scenario (closed app)

Actions to reproduce behaviour:

  1. Turn off the screen
  2. Run application from Android Studio (at this point no lifecycle method has been called yet)
  3. Turn on the screen

Here's the launcher activity lifecycle:

// we turn on the screen

  • onCreate()
  • onStart()
  • onResume()

// launcher activity here suddenly decides to stop and restart

  • onPause() // Is this a BUG?
  • onStop()
  • onRestart()
  • onStart()
  • onResume()

B. Lock-screen scenario

Actions to reproduce behaviour:

  1. Turn off the screen (you should have a lock screen)
  2. Send push to your app
  3. Open the lock screen and click on push notification

C. Scenario when activity was already opened

Actions to reproduce behaviour:

  1. Open your app (in launcher activity)
  2. Turn off the screen
  3. Send push
  4. Open push from lock screen

Here's the launcher activity lifecycle:

// open activity like a normal person :)

  • onCreate()
  • onStart()
  • onResume()

// turn off the screen causes onStop(), everythin OK

  • onPause()
  • onStop()

// send push and click it from lock screen

  • onRestart() // FIRST RESTART because we stopped activity, it's OK
  • onStart()
  • onResume()
  • onPause() // Is this a BUG?
  • onStop()
  • onRestart()
  • onStart()
  • onResume()
  • onPause()
  • onStop()

Finally

This lifecycle order and restarting does not seem very reasonable to me. Does anyone have any idea why this happens?

Fahim Al Mahmud Ashik
  • 1,083
  • 10
  • 26
soshial
  • 5,906
  • 6
  • 32
  • 40

0 Answers0