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.How to propose permission to use the telephone function when installing my application.
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.Currently the user must go himself to the app settings to authorize this function.
but I don't know how !!!
AddPermission(android.permission.CALL_PHONE)
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
Hi Drgottjr,and othersall 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 !!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.
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
See Android Tutorial Runtime Permissions (Android 6.0+ Permissions)Hi Drgottjr,and others
I wonder that how do you know for coding. Is there strategy to remember how coding?
If the user has given permission, you no longer have to ask for permission. See Android Tutorial Runtime Permissions (Android 6.0+ Permissions)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
OK, Thank youIf 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.