Android Question How to avoid "Function not available" warning message on a device that does not allow it ("Display over other apps")

vecino

Well-Known Member
Licensed User
Longtime User
Hi, a customer has an android v11 device that the manufacturer has removed the ability to use the permission feature to run on other applications.
"Display over other apps", so whenever he starts my application he gets the screen with the warning that this function is not available.
My question is how can it detect if that option is available, so that it doesn't make the function call to avoid that warning/error message from Android.
And leave it for other devices that do allow it.
Thanks.
 

vecino

Well-Known Member
Licensed User
Longtime User
I had thought of something like this:

B4X:
Public Sub GetPermission As ResumableSub
    If phone.SdkVersion >= 23 Then
        Dim settings As JavaObject
        settings.InitializeStatic("android.provider.Settings")
        Dim ctxt As JavaObject
        ctxt.InitializeContext
        If settings.RunMethod("canDrawOverlays", Array(ctxt)) = True Then
            Return True
        else     '  <------
            Return False  '  <------
        End If
        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 settings.RunMethod("canDrawOverlays", Array(ctxt))
    Else
        Return True
    End If
End Sub

Because the android warning screen comes up when running StartActivityForResult(i)
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It seems to be a very complicated matter, although I think that the information that you have linked to me will be useful.
Thank you very much.
 
Upvote 0
Top