No Auto Sleep ? (75d)

Monkey Targets Forums/Android/No Auto Sleep ? (75d)

Fred(Posted 2013) [#1]
I'm about to release an Android App with 75d, but I just noticed that the phone never goes to sleep if you don't touch it at all.
Is there a way to control the behavior of auto sleep ?


Volker(Posted 2013) [#2]
http://www.monkeycoder.co.nz/Community/posts.php?topic=3538

HTH.


Fred(Posted 2013) [#3]
Thanks Wolker, I didn't search enough...

android:keepScreenOn="false" allows the device to automaticaly go to sleep if you don't touch it for a while.

But it doesn't really solve my issue:

I want the game to let the phone goes to sleep if left on the menu but not when it is self playing the demo.

with keepScreenOn set to false it goes to sleep while playing the demo and it continues running with the screen off as we can hear the sounds ! I guess OnSuspend should be called then ?

Back to keepscreenon to true.


computercoder(Posted 2013) [#4]
Thats not a bad thought Fred.

Use the OnSuspend() with a flag that is set to know if the user requested the change or the system did. If the system did, then force it to stay awake; otherwise allow the app to pause and let the device sleep.

Use OnResume() to reactivate the game.


Fred(Posted 2013) [#5]
Oh ! This looks like so violent ! :) and a clever idea too!
I'll give it a try and use it for the next version, thanks you!