2

This app needs the device (and its display) to stay awake between onPreExecute() and onPostExecute().

jacknad
  • 13,483
  • 40
  • 124
  • 194

3 Answers3

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
2

It's definitely possible - here's an example of an app which does that:

http://www.appsbeyond.com/apps/screen-suite

DVK
  • 126,886
  • 32
  • 213
  • 327
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).

Developer Reference

rask004
  • 552
  • 5
  • 15