What in Monkey code keeps the device awake?

Monkey Targets Forums/Android/What in Monkey code keeps the device awake?

secondgear(Posted 2012) [#1]
Does anybody know how Monkey keeps an Android device awake? In my Android apps I had to use WakeLock, but there is no sign of it in Monkey-generated code.

I need to be able to allow the device to fall asleep as usual, even if my Monkey app is in foreground. My only ugly workaround now is to exit the app after some period of inactivity, but this way users wouldn't be happy to come back to the device and find out they lost their context.

Any ideas?


therevills(Posted 2012) [#2]
I believe its in the Manifest... Hmmm I thought it was in there...


secondgear(Posted 2012) [#3]
I think I found the answer: layout/main.xml has android:keepScreenOn="true" for MonkeyView.


therevills(Posted 2012) [#4]
Yep thats it!

\MonkeyPro\targets\android\templates\res\layout


Gerry Quinn(Posted 2012) [#5]
What's best practice for games? Or are both approaches equally annoying depending on the user's mood?


secondgear(Posted 2012) [#6]
@Gerry Quinn
It really depends on the app. If the game has natural long periods of inactivity where player is just watching the action, then keeping screen on is a good practice. If the game normally requires constant user input, then the absence of input for a long time means the player is away from the device. In this case, you are better off allowing the device to sleep. In my experience, the best practice in this case is not to auto-resume game the way Monkey does, but to display a "game paused" dialog and allow the user to resume the game manually (which is doable with a bit of extra code).

My latest app is essentially an interactive electronic book, so letting the device sleep was important.


golomp(Posted 2012) [#7]
precious information i was also searching for.
Thanks!