Sweeper
Sweeper

Reputation: 271535

What activity lifecycle method is called when the user switches off the monitor

I have an android activity. If the user switches off the monitor of the android device for some time and then switches back on again, It seems like that the current activity is restarted. I found an activity lifecycle picture on the Internet but it does not tell me what method is called when the user switches off the monitor. It only tells me that when the activity is running, and "another activity comes in front of the activity", the onPause() method is called. But a "black screen" is not "another activity", right?

So what is called when the device's monitor is switched off?

Upvotes: 2

Views: 2765

Answers (2)

Rashmi Jain
Rashmi Jain

Reputation: 373

Activity lifecycle methods and state

onResume() called- Visible
onPause() called - Partially Visible
onStop() called - Invisible

If app is in memory, then onRestart call when app starts again, otherwise onCreate() called

Upvotes: 1

BNK
BNK

Reputation: 24114

onPause will be called first, then onStop will be called

enter image description here

Upvotes: 3

Related Questions