Sub Class_Globals
Private ion As Object
End Sub
Public Sub Initialize
End Sub
Public Sub GetPermission As ResumableSub
Dim jo As JavaObject
jo.InitializeStatic("android.provider.Settings")
Dim ctxt As JavaObject
ctxt.InitializeContext
' // we already have it
If jo.RunMethod("canDrawOverlays", Array(ctxt)) = True Then
Return True
End If
' // request it
Dim i As Intent
i.Initialize("android.settings.action.MANAGE_OVERLAY_PERMISSION", "package:" & Application.PackageName)
StartActivityForResult(i)
Wait For ion_Event (MethodName As String, Args() As Object)
Return jo.RunMethod("canDrawOverlays", Array(ctxt))
End Sub
Private Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Private Sub GetBA As Object
Dim jo As JavaObject = Me
Return jo.RunMethod("getBA", Null)
End Sub