ScreenOn
Toggles the screen to always be on or not always on.
 Specifications
 Created: 2025-05-09T23:00:00Z
 Size: 4.10 KB
 Version: 1.0
 Minimum API Level: 7
 Latest Update: 2025-05-09T23:00:00Z
 Built & documented using: FAST v3.1.0
Blocks:
ScreenAlwaysOn
sets the existing window to always on or not always on, use true or false blocks

| Parameter | Type | 
|---|---|
| status | boolean | 
IsScreenAlwaysOn
status of ScreenAlwaysOn
![]()
- Return type: 
boolean 
Example Usage:

AIX
uk.co.metricrat.screenonV1.aix
Source
package uk.co.metricrat.screenon;
//ref: https://developer.android.com/develop/background-work/background-tasks/awake/screen-on
import android.app.*;
import android.view.*;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
@DesignerComponent(
	version = 1,
	versionName = "1.0",
	description = "Toggles the screen to always be on or not always on. Developed by TIMAI2, built using Fast.",
	iconName = "icon.png"
)
public class ScreenOn extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    private final Activity activity;
    private boolean sao = false;
  public ScreenOn(ComponentContainer container) {
      super(container.$form());
      this.container = container;
      this.activity = container.$context();
  }
  @SimpleFunction(description = "sets the existing window to always on or not always on, use true or false blocks")
  public void ScreenAlwaysOn(boolean status) {
      sao = status;
      if (status) {
          this.activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      } else {
          this.activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      }
  }
  @SimpleProperty(description="status of ScreenAlwaysOn")
    public boolean IsScreenAlwaysOn() {
      return sao;
  }
}
Enjoy 
 , and all feedback and comments welcome.
Available for use in any MIT AppInventor projects or competitions
#####################################################################
This work by TIMAI2 is licensed under a
Creative Commons Attribution-ShareAlike 4.0 Unported License  with attribution.
Please use name = TIMAI2 and link to this source page when giving credit.
#####################################################################