This app needs the device (and its display) to stay awake between onPreExecute() and onPostExecute().
Asked
Active
Viewed 7,439 times
3 Answers
7
Use a "full" PowerManager.WakeLock
like in this post.
eg:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
wl.acquire();
Add permission to manifest file
<uses-permission android:name="android.permission.WAKE_LOCK"/>
Make sure to release it when done.

Community
- 1
- 1

Paul Burke
- 25,496
- 9
- 66
- 62
-
2Thanks--works great! Also need to add android.permission.WAKE_LOCK to manifest. – jacknad Sep 07 '10 at 18:41
1
"full" PowerManager.WakeLock is now deprecated and will lose support.
For future compatibility, use the following to force the app to stay awake:
// keep awake
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// allow suspend
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
No special permissions are required.
You will need to do this in the hosting activity. you could try nesting the AsyncTask, or using a callback interface implemented by the host Activity (think Fragment callbacks).

rask004
- 552
- 5
- 15