keep Screen On - Android android.app

Android examples for android.app:Screen

Description

keep Screen On

Demo Code

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

public class Main{

    public static void keepScreenOn(Activity activity, boolean flag) {
        if (flag) {
            activity.getWindow().addFlags(128);
            return;
        } else {//from  w  ww . j  a  va  2  s  . c o  m
            activity.getWindow().clearFlags(128);
            return;
        }
    }

}

Related Tutorials