1

I was reading about the Activity Lifecycle and it says that after onPause() and onStop() the Activity/Process is killable from the System.

If I have this in onPause():

{
    Thread.sleep(20000)
}

Is the activity killable in those 20s or after it finishes the onPause() method?

Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
Nick
  • 2,818
  • 5
  • 42
  • 60

1 Answers1

2

If you have that in onPause(), you're going to be killed by the watchdog timer and see an ANR anyway. onPause() and other lifecycle methods need to process quickly. Here's official documentation on what triggers ANR.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Okk but regardless of the ANR, if lets say is Thread.sleep(3000) its not killable in those seconds, right ? – Nick Sep 17 '18 at 12:40