So, yesterday I spent 30 minutes trying to figure out a good way to stop my phone from going to sleep while my application is running so I thought I'd post it here.
In your main activity (the one that extends SlickActivity) add the following line to your onCreate method:
Code:
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
Then, in your manifest file, right beneath your manifest definition, make sure you add the following line:
Code:
<uses-permission android:name="android.permission.WAKE_LOCK" />
After you add that line, the beginning of your manifest file should look something like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mangelok"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.WAKE_LOCK" />
That's it! Now your app will automatically keep your phone screen on unless you push the power button causing it to go to sleep.
Hope this helps someone.