smilevchy
5/23/2015 - 1:53 PM

ActivityUtils.java

public class ActivityUtils {

	public static void requestFullscreen(final Activity activity) {
		final Window window = activity.getWindow();
		window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
		window.requestFeature(Window.FEATURE_NO_TITLE);
	}


	/**
	 * @param pActivity
	 * @param pScreenBrightness [0..1]
	 */
	public static void setScreenBrightness(final Activity activity, final float screenBrightness) {
		final Window window = activity.getWindow();
		final WindowManager.LayoutParams windowLayoutParams = window.getAttributes();
		windowLayoutParams.screenBrightness = screenBrightness;
		window.setAttributes(windowLayoutParams);
	}

	public static void keepScreenOn(final Activity activity) {
		activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	}
}