'this requires the Reflection library
'checks if screen is on, that is not in sleep modus
'This code is in a code module called Screenstate
Sub IsScreenOn As Boolean
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "power", "java.lang.String")
Return r.RunMethod("isScreenOn")
End Sub
'Use this in the main activity
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim ScreenOn, PromptForPassword As Boolean
End Sub
Sub Activity_Resume
If PromptForPassword = True Then
'Write your code for password check
PromptForPassword = False
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ScreenOn = ScreenState.IsScreenOn
If ScreenOn = False Then
PromptForPassword = True
End If
End Sub
'Use this in every sub activity
Sub Activity_Pause (UserClosed As Boolean)
Main.ScreenOn = ScreenState.IsScreenOn
If Main.ScreenOn = False Then
Main.PromptForPassword = True
Activity.Finish 'go to main
Else
Main.PromptForPassword = False
End If
End Sub