Android Question error permission READ_PHONE_STATE

Roberto P.

Well-Known Member
Licensed User
Hi,
I've a problem when use below function:

B4X:
    Dim ph                         As PhoneId
     m_device_id                =    ph.GetDeviceId

Error in ReadDeviceData (SecurityException) java.lang.SecurityException: getDeviceId: Neither user 10143 nor current process has android.permission.READ_PHONE_STATE.

this is the code that I added to manifest

B4X:
AddPermission(android.permission.READ_PHONE_STATE)

thank in advance
regards
 

Mahares

Expert
Licensed User
I've a problem when use below function:
Try to also add this code to your Activity_Resume:
B4X:
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)  '
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        MsgboxAsync("No permission to phone ID", "")
        Return
    Else
        Log("Granted")
        Dim ph  As PhoneId
        Dim m_device_id  As String  = ph.GetDeviceId
        Log(m_device_id)  'will display phone ID
    End If
 
Upvote 0
Top