The lock screen does not call onStop () to call

My application uses GPS, so I delete GPS updates on onStop (), so it does not use the battery if it is not. However, I noticed that the battery on my test phone worked if my application was open when the lock screen is on.

So, to test this, I added Log.i (...) to the onStop () method of my activity. Of course, onStop () is not called when I press the off button on my HTC Incredible (which turns off the screen).

Is there a way to listen to the lock screen or turn off the screen since it does not call onStop (), how should it be?

Thanks.

+4
source share
1 answer

onStop cannot be called, onPause is. Use onPause to remove GPS updates from battery.

+10
source

Source: https://habr.com/ru/post/1337871/


All Articles