Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / How to allow android app to sleep - removing prevent screen from sleeping

Author
Message
Naphier
9
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 22nd Jan 2014 01:17
I was able to get in touch with Paul and he gave me the code that allows AppGameKit Android apps to allow screen sleep. Since we really didn't like that our apps prevent screen sleep this was very important to us.
In main.c you will find a line that reads:
ANativeActivity_setWindowFlags( state->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0 );
Remove or comment out this line.

Next find APP_CMD_INIT_WINDOW and change that case to read like so:


Then recompile with cygwin and you should be all set.
You may be able to remove the Android manifest permission for wake lock, but you cannot do that if you use push notifications as GCM requires wakelock.
This has also removed issues we were seeing where folks would shut off the screen when the app was active then return to a black screen.

Enjoy!

=PRoF=
16
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 26th Feb 2014 14:12
Thanks for sharing, this will be useful

Login to post a reply

Server time is: 2019-10-16 23:28:46
Your offset time is: 2019-10-16 23:28:46