Android Question Permission Denial: starting intent..........with revoked permission android.permission.CALL_PHONE

Jakes72

Active Member
Licensed User
Longtime User
Hi Experts,

Can someone please help?
I am trying to dial a phone number like this:
StartActivity(PhoneCalls.Call("xxxxxxxxxx")) <----- xxxxxx = the number I want to dial, but I get the above error (in the subject line).

I am trying this in debug mode at this stage, my manifest is set to minSdkVersion = "5" and android:targetSdkVersion = "26".

I know I must set a permission somewhere, but I have no clue how to do this?
I have tried adding this to manifest:
AddPermission(android.permission.CALL_PRIVILEGED)
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.CALL_PHONE)

But it does not solve the error, please advise.

Many thanks,
Jacques.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Jakes72

Active Member
Licensed User
Longtime User
1. Please post the FULL Error
2. The error seen suggest you do not have the permission to CALL_PHONE. Maybe revoked by the user?
Are you using Runtimepermission and request the permission at runtime? You should. See this thread

android.jar / targetSdkVersion / minSdkVersion

Especially RuntimePermissions

Hi Don,

Thanks for your reply. I had a look at the article 'RunTimePermissions' but I can see nothing to do with the phone there?
Is there someone that has working code to dial a number perhaps?

Regards,
Jacques.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is there someone that has working code to dial a number perhaps?
The code you are using works if you request the correct permission before you use it. Surely you only can use the Call if you successfully get permission from Android.

The Requirements has changed. You need to follow them to further use this Method.

I suggest to watch the Tutorial and adapt your Code.

 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but I can see nothing to do with the phone there?
The Runtimepermissions tutorial describes how to find out "dangerous Permissions". Every dangerous permission needs requested using Runtimepermissions.

If i add your Code to an app i can see the following Permissions needed
dangpermissions021.png


CALL_PHONE and READ_PHONE_STATE needs to get requested before you can use the following code
B4X:
    Dim p As PhoneCalls
    StartActivity(p.Call("1234567890"))

Working code:
B4X:
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CALL_PHONE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then Return
    ' PERMISSION_CALL_PHONE includes phone state
    Dim p As PhoneCalls
    StartActivity(p.Call("123456789"))
 
Last edited:
Upvote 0

saeed10051

Active Member
Licensed User
Longtime User
This starter.rp works directly or do we need to import/add some reference to it also. is it there in Phone library
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This starter.rp works directly or do we need to import/add some reference to it also. is it there in Phone library
 
Upvote 0
Top