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.