Android Question Handle multiple permission request

Discussion in 'Android Questions' started by Shay, Jun 29, 2018.

  1. Shay

    Shay Well-Known Member Licensed User

    I have in my app multiple permission requests, such as:

    I wish that app will start only if the above will approve (since no point opening the app without it)
    what is the best way to handle such
    superkan likes this.
  2. BillMeyer

    BillMeyer Well-Known Member Licensed User

    You could possibly use this:

    Sub Activity_PermissionResult (Permission As String, Result As Boolean)
         gmap.MyLocationEnabled = Result
    ' Credit for the following code to DonManfred
             rs= Msgbox2("You have not given permission - I can not proceed"    ,"Permission Failure","Yes","Cancel","No",Null)
    If rs=DialogResponse.POSITIVE Then
    Return True ' RETURN TRUE to consume the Event---
       End If
    End Sub
    Example discussion here

    I have not tested - but I have faith that it will work.

    Enjoy !!
  3. Shay

    Shay Well-Known Member Licensed User

    Yes, but this handle 1 permission, how do I handle multiple?
    superkan likes this.
  4. BillMeyer

    BillMeyer Well-Known Member Licensed User

    Multiple If Statements.

    Process --> Check and Request --> Permission Result --> If statement --> Return --> Check next permission --> Repeat Process.

    Let's presume you have 3 permissions.

    Check the first one - user accepts - so it's OK

    Check the second one - user accepts - so it's OK

    Check the third one - user does NOT accept - so app does not execute.

    Enjoy !!
  5. Erel

    Erel Administrator Staff Member Licensed User

    Edit: don't put this code in Activity_Resume. Request the permissions right before you need them.
    Activity_Resume can be called multiple times during the requests and it can cause some requests to fail.

    Sub Activity_Resume
    Wait For Activity_PermissionResult (permission As String, Result As Boolean)
    If Result = False Then
    ToastMessageShow("No permission!"True)
    End If
    'we have permission!
    End Sub
    Last edited: Jun 12, 2019
  6. Shay

    Shay Well-Known Member Licensed User

    Great thanks, b.t.w I saw app's that created layout just for the permissions as first screen, which I think good approach
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice