I am mobile right now so I cannot provide a portion of my code, my widget service is up and running. Upon clicking the widget it is supposed to invoke the screen lock..
Mind you this is still alpha build as there is lots to be added. I'm pretty sure the screen lock code is correct.
If not, I could use some constructive criticism.
Mind you this is still alpha build as there is lots to be added. I'm pretty sure the screen lock code is correct.
If not, I could use some constructive criticism.
B4X:
MAIN
Sub LockScreen
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "keyguard", "java.lang.String")
r.Target = r.RunMethod2("newKeyguardLock", "keyguard", "java.lang.String")
r.RunMethod("reenableKeyguard")
End Sub
Sub OnOff_CheckedChange(Checked As Boolean)
If OnOff.Checked=True Then
ToastMessageShow("Service Started",True)
End If
If OnOff.Checked=False Then
ToastMessageShow("Service Terminated",True)
Service_Destroy
End If
End Sub
Sub Service_Destroy
End Sub
Sub ImageView1_Click
LockScreen
ToastMessageShow("Device Locked",True)
End Sub
B4X:
Widget
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim rv As RemoteViews
End Sub
Sub Service_Create
rv = ConfigureHomeWidget("Lock", "rv",0, "SecureLock")
End Sub
Sub Service_Start (StartingIntent As Intent)
If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub
Sub rv_RequestUpdate
rv.UpdateWidget
End Sub
Sub rv_Disabled
StopService("")
End Sub
Last edited: