Reputation: 13739
This app needs the device (and its display) to stay awake between onPreExecute() and onPostExecute().
Upvotes: 2
Views: 7531
Reputation: 590
"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).
Upvotes: 1
Reputation: 25584
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.
Upvotes: 7
Reputation: 129363
It's definitely possible - here's an example of an app which does that:
http://www.appsbeyond.com/apps/screen-suite
Upvotes: 2