Android examples for android.app:Screen
set Keep Screen On
import android.app.Activity; import android.view.WindowManager; public class Main{ public static void setKeepScreenOn(final Activity activity, final boolean keepScreenOn) { // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED if (keepScreenOn) { activity.getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else {/*w ww. j a v a2 s . c om*/ activity.getWindow().clearFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } }