Android Question Phone Permission at installation

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
How to propose permission to use the telephone function when installing my application. Currently the user must go himself to the app settings to authorize this function.
THANKS
 

MicroDrie

Well-Known Member
Licensed User
How to propose permission to use the telephone function when installing my application.
In the past, it was very tempting to unknowingly use a permission during installation that could be abused later. Google has therefore raised the bar on security policy in recent years by defining dangerous permissions that can be abused.
Currently the user must go himself to the app settings to authorize this function.
The idea behind this is to make the software user aware of the security risks by consciously asking her or him to agree to the requested permission to use a permission.

Without a specific example it is difficult to answer your question. Perhaps a solution with runtime persie is a good solution because you only have to bother the user once to give permission after installation.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Thank you very much for your answer. I would like permission to use phone calls to be offered when installing the app. Currently only location authorization is offered.
I imagine I have to use "AddPermission(android.permission.CALL_PHONE" but I don't know how !!!
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
but I don't know how !!!

all right, calm down. it's just like you did for location:

in the manifest:
B4X:
AddPermission(android.permission.CALL_PHONE)

and in the app:
B4X:
Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    if result then
        StartActivity(pe.Call("+341837798989"))
    else
        activity.finish
    end if

End Sub

if i understand you correctly, you also have location permission, so you'll have to ask for 2 permissions and check the result for each before making the call.
note: the permission is checked for (and granted) when the user runs the app for the first time. if permission(s) is/are not granted, then user would have to go into settings for the app to change their preferences.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
all right, calm down. it's just like you did for location:

in the manifest:
B4X:
AddPermission(android.permission.CALL_PHONE)

and in the app:
B4X:
Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    if result then
        StartActivity(pe.Call("+341837798989"))
    else
        activity.finish
    end if

End Sub

if i understand you correctly, you also have location permission, so you'll have to ask for 2 permissions and check the result for each before making the call.
note: the permission is checked for (and granted) when the user runs the app for the first time. if permission(s) is/are not granted, then user would have to go into settings for the app to change their preferences.
Hi Drgottjr,and others
I wonder that how do you know for coding. Is there strategy to remember how coding?
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
all right, calm down. it's just like you did for location:

in the manifest:
B4X:
AddPermission(android.permission.CALL_PHONE)

and in the app:
B4X:
Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    if result then
        StartActivity(pe.Call("+341837798989"))
    else
        activity.finish
    end if

End Sub

if i understand you correctly, you also have location permission, so you'll have to ask for 2 permissions and check the result for each before making the call.
note: the permission is checked for (and granted) when the user runs the app for the first time. if permission(s) is/are not granted, then user would have to go into settings for the app to change their preferences.
Thanks a lot. Now, if I want the user to authorize the use of CALL PHONE just after installation and at the start of the first use, can I place the code when loading the main activity like this: Or should the verification be done with each phone call? Merci et désolé pour mon mauvais anglais !!
B4X:
Sub Activity_Create(FirstTime As Boolean)
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    if result then
        Activity.LoadLayout("Main")
    else
        activity.finish
    end if
End Sub
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Thanks a lot. Now, if I want the user to authorize the use of CALL PHONE just after installation and at the start of the first use, can I place the code when loading the main activity like this: Or should the verification be done with each phone call? Merci et désolé pour mon mauvais anglais !!
B4X:
Sub Activity_Create(FirstTime As Boolean)
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    wait for activity_PermissionResult (Permission As String, Result As Boolean)
    if result then
        Activity.LoadLayout("Main")
    else
        activity.finish
    end if
End Sub
If the user has given permission, you no longer have to ask for permission. See Android Tutorial Runtime Permissions (Android 6.0+ Permissions)
I don't think it is very user-friendly to abort the program without mentioning that this is happening because the necessary permission has not been given or has been revoked. And also useful, what the user has to do to give permission.
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top