Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No need for using the wakelocks, as they are unreliable and buggy.</p> <p>It would be more efficient to use the system's own version of keeping the screen on in a manageable way that is taken care of by Android:</p> <p>Within the <code>onCreate</code> in your activity, do this:</p> <pre><code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.FLAG_SHOW_WHEN_LOCKED); </code></pre> <p>This is from the developer's API found <a href="http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED" rel="nofollow">here</a>:</p> <blockquote> <p>public static final int FLAG_SHOW_WHEN_LOCKED</p> <p>Since: API Level 5 Window flag: special flag to let windows be shown when the screen is locked. This will let application windows take precedence over key guard or any other lock screens. Can be used with FLAG_KEEP_SCREEN_ON to turn screen on and display windows directly before showing the key guard window. Can be used with FLAG_DISMISS_KEYGUARD to automatically fully dismisss non-secure keyguards. This flag only applies to the top-most full-screen window.</p> <p>Constant Value: 524288 (0x00080000)</p> </blockquote> <p>By combining it with the efficient screen on flag, should get around the screen-lock facility. The only thing is to <em>make sure that your activity is the top-most on screen</em>.</p> <p>To quote, on the usage of <code>FLAG_KEEP_SCREEN_ON</code> of <a href="http://developer.android.com/reference/android/os/PowerManager.html" rel="nofollow">PowerManager</a></p> <blockquote> <p>public static final int SCREEN_BRIGHT_WAKE_LOCK</p> <p>This constant is deprecated. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission. Wake lock that ensures that the screen is on at full brightness; the keyboard backlight will be allowed to go off.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload