Android Utililty Methods Screen On

List of utility methods to do Screen On

Description

The list of methods to do Screen On are organized into topic(s).

Method

voidkeepScreenOn(final Activity pActivity)
keep Screen On
pActivity.getWindow().addFlags(
        WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
voidkeepScreenOn(final Activity pActivity)
keep Screen On
pActivity.getWindow().addFlags(
        WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
voidturnScreenOn(Activity context)
Purpose - Force screen to turn on if the phone is asleep.
if (context == null)
    return;
try {
    Window window = context.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
} catch (Exception ex) {
...