Android Question [SOLVED] java.lang.SecurityException: getLine1NumberForDisplay: Neither user 10368 nor current process has android.permission.READ_PHONE_STATE

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I changed my Manifest from android:targetSdkVersion=28 to android:targetSdkVersion=30.

Now I got this error on my code:
B4X:
Public Sub Aanwezig06Nr As Boolean
    Dim myphone As PhoneId 'need phone lib
    If(myphone.GetLine1Number="") Then
        Return False
    Else
        Return True
    End If
End Sub

I do have:
B4X:
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

in my Main Activity_Create and SdkVersion=28 works fine.

Do I need something to add to my Manifest?

Kind regards,
André
 

agraham

Expert
Licensed User
Longtime User
See the "Phone Numbers" section here

You now need the READ_PHONE_NUMBERS permission, instead of the READ_PHONE_STATE permission.

I haven't tried this for this particular new permission but the request permission string is

"android.permission.READ_PHONE_NUMBERS"

and you need to add to the manifest

AddPermission(android.permission.READ_PHONE_NUMBERS)
 
Upvote 1

AHilberink

Active Member
Licensed User
Longtime User
See the "Phone Numbers" section here

You now need the READ_PHONE_NUMBERS permission, instead of the READ_PHONE_STATE permission.

I haven't tried this for this particular new permission but the request permission string is

"android.permission.READ_PHONE_NUMBERS"

and you need to add to the manifest

AddPermission(android.permission.READ_PHONE_NUMBERS)

Hi,

Thank you very much. This is something to change.

Changing it within the manifest and requested permission, still gives the error, but removing the App and install it again everything is working fine.

Is there a way to prevent this?
I can not tell my users to re-install. For now I will set my android:targetSdkVersion below 30.

Kind regards,
André
 
Upvote 0
Top