Android Question RuntimePermission

MarcoRome

Expert
Licensed User
Longtime User
Hi all.
I need to implement RuntimePermission ( SDK 23 ) .
I have the following situation

upload_2016-9-23_15-44-8.png


Now i want that when start application ask all permission. so i write in code this:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim rp As RuntimePermissions
End Sub
....
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lay_xx")
    rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
Log($"Permission: ${Permission}
Result: ${Result}"$)

  
    Select Permission
        Case rp.PERMISSION_READ_PHONE_STATE
            If Result Then rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        Case rp.PERMISSION_WRITE_EXTERNAL_STORAGE
            If Result Then rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
        Case rp.PERMISSION_CALL_PHONE
              If Result Then rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
        Case rp.PERMISSION_ACCESS_FINE_LOCATION
            If Result Then rp.CheckAndRequest(rp.PERMISSION_READ_EXTERNAL_STORAGE)
        Case rp.PERMISSION_READ_EXTERNAL_STORAGE
            If Result Then rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
        Case rp.PERMISSION_RECORD_AUDIO
            If Result Then permessi_accordati
    End Select
End Sub

In this mode the customer have all Request Permission.
There is no faster way, instead of asking all these permissions ?
Such example in manifest or another way ?
Thank you
Marco
 

DonManfred

Expert
Licensed User
Longtime User
Now i want that when start application ask all permission. so i write in code this
The google guidelines states that you need to request A permission when you first want to use them.
i´m not sure your code is correct...

Activity_PermissionResult
is called whenever you request a permission and got the result for this request.. OR the user remove the permission.

In fact; when the code
B4X:
Select Permission
        Case rp.PERMISSION_READ_PHONE_STATE
is running you already got the permission if result = true. No need to request again

Same for all other permissions
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
I think that this new policy about "Runtime Permission" is very annoying, so the only way is to set SDK < 23.
 
Upvote 0

b2mvga

Member
Licensed User
Longtime User
I have same MarcoRome problem... I define by oversight on manifest <uses-sdk android:minSdkVersion="24"/> and publish app on google play and now when app need one permission then not works... Google play not permit I put a new version with android:minSdkVersion="22" :(

I have to put runtime permissions in my app now...
 
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User
HELLO jajja not sorry copy a text that had nothing to do with this nor is it what they think.
 
Upvote 0
Top