I am writing this question because I have not found any way to get this. When the screen of the device is in standby or off, my application needs to close. I saw finishAffinity()
, which works well, but how do I know when the screen turns off?
Asked
Active
Viewed 57 times
0

user2847219
- 555
- 1
- 16
- 27
-
3Why does your app need to close when the screen is off? This goes against the design of the Android platform and isn't the recommended way of doing things. You should be handling lifecycle changes instead. – NoChinDeluxe Dec 22 '15 at 19:00
-
with that, just close whenever you receive the action screen off – njzk2 Dec 22 '15 at 19:05
-
1@NoChinDeluxe not all apps fit perfectly in the android recommendation. It is perfectly possible that this app has a valid reason for doing so, and I don't think you should make vague suggestions like that until you know more. – njzk2 Dec 22 '15 at 19:07
-
@njzk2 it was just what I wanted. Thank you – user2847219 Dec 22 '15 at 19:12
-
@njzk2 - That's why it was a comment and not an answer. – NoChinDeluxe Dec 22 '15 at 20:22