Which activity lifecycle method gets called whenever the screen of the device turns off an then turns on?

Asked 22-Jan-2018
Viewed 627 times

1

Which activity lifecycle method gets called whenever the screen of the device turns off an then turns on?


1 Answer


0

onPause() method will be called right before the screen turns off and onResume() method will be called right before the screen turns on.

onPause() method of the activity lifecycle is called when the user is leaving the activity. for example, we can use this in music player where we pause the music when activity is paused and resumed shortly after user comes back.

onResume() method is called as soon as the user returns to the activity. whenever any interruption occurs the activity moves to the Pause state and system will call the onPause method. the onResume invocation means that the activity moves in the foreground.