Hi Erel,
Unfortunately, I am still not able to get this to work successfully.
With the code below, the application goes to a keyguard lock state if keyguard lock timer is 30 sec. It does not return from this state without unlocking the keyguard manually.
If keyguard lock is 10 to 30minutes, the screen does not dim - this is expected as keyguard lock timer is 30 minutes.
I have added a different approach to this - using screenbrightness(0) to blank the screen. This also results in a black screen, but also a keyguard lock - irrespective of the keyguard lock timer (it was 30min for the test above).
FURTHER TO COMMENTS ABOVE:
I have found using screenbrightness(0) engages the keyguard & pauses the activity - even when keepalive is used. Is there a way to blank the screen without engaging the keyguard?
Sub Timer1_Tick
If switch = True Then
StartActivity(Main)
CallSubDelayed(Main, "callbackawake")
switch = False
Else
StartActivity(Main)
CallSubDelayed(Main, "callbacksleep")
switch = True
End If
End Sub
Also, I have attached the sleep and awake subroutines in main:
Sub callbackawake
ToastMessageShow("Awake sub called", False)
'Phone1.SetScreenBrightness(-1)
Phone2.KeepAlive(True)
End Sub
Sub callbacksleep
ToastMessageShow("Sleep sub called", False)
Phone2.ReleaseKeepAlive
'Phone1.SetScreenBrightness(0)
End Sub
I have tried a more extreme solution - using keepalive and screenrightness(0)
together. This worked poorly as I needed to use the power button to get the display back to normal brightness.
I suspect a contibuting factor is the activity itself is pausing during the execution.
Any further advice would be very helpful.
Thanks,
refsmmat