Share My Creation Block Phone Screen from turned off

Name: TDScreenOnOFF
Version: 1

This solution gives the user the possibility tu override the phone screen off timeout. The settings values will not affected (Button btAn). After override the button color turns yellow. After doing his actions while the screen is on the user is able to reset back to the standard settings screen timeout (Button btClose) the button color turns back to blue.

Do not forget to reset the override back because screen on means to consumpt battery energy. Reset is done by clicking button btAn again or closing the App with button btClose. Do not close the App with the phones navigation bar.

Find the needed code here and put it in an Activity Project in the Activity Main:

Code Main Activity:
#Region  Project Attributes
    #ApplicationLabel: TDScreenOnOff
    #VersionCode: 1
    #VersionName: TDScreenOnOFF
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Private xui As XUI
End Sub

Sub Globals
    Private PWS As PhoneWakeState
    Private statusAn As Boolean = False
    Private btAn As Label
    Private btClose As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.Title = "TDScreenON: Bildschirm immer an?"
End Sub

Private Sub btClose_Click
    ' reset screen on to phone standard
    ' close all activities
    Dim jo As JavaObject
    jo.RunMethod("finishAffinity", Null)
End Sub

Private Sub btAn_Click
    ' toogle status
    statusAn = Not(statusAn)
    If statusAn Then
        ' disable phone standard screen timeout
        ' set button param
        btAn.Color = Colors.yellow
        btAn.Text = "Bleibt immer an!"
        ' enable phone standard screen timeout
        ' set button param
        btAn.Color =
        btAn.Text = "Ja, immer anschalten."
    End If
End Sub

You need a layout file called "layout.bal" with two buttons btAn and btClose. An you must activate the phone-library.