Stop screen dimming / turning off

Monkey Targets Forums/Android/Stop screen dimming / turning off

therevills(Posted 2011) [#1]
Can we stop the screen dimming and can we stop the screen sleeping?

On my MonkeyPong Game the user doesnt touch the screen and just tilts the device, so after a minute the screen dims...


Virtech(Posted 2011) [#2]
I believe this is the normal behaviour for any app running on android. Not just monkey apps. No need wasting battery if you are not using the app. Anyway, it would be nice having an option to prevent dimming if you wish so.


therevills(Posted 2011) [#3]
I play a game called Wild West Sheriff and on the main game I left it for over 1:30 (after that I died) and the screen didnt dim. On my Monkey game it dims after 40 seconds...


therevills(Posted 2011) [#4]
From the Blitz forums Jim has pointed out that this is due to power management, we need something like this:

Function OnCreate()
   PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
   PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
   wl.acquire()
End

Function OnSuspend()
  wl.Release()
End Function


And in the manifest:
<uses-permission android:name="android.permission.WAKE_LOCK" />