Android Question get ime in android 7

SMOOTSARA

Active Member
Licensed User
Longtime User
hi
How can I get an IME value on Android 7 or 8 ?
i used this cod but not work!


B4X:
Try
        manifest:AddPermission(android.permission.READ_PHONE_STATE)
        Dim p As PhoneId
        p.GetDeviceId
        map_information.Put("device_imei",p.GetDeviceId)
    Catch
        map_information.Put("device_imei", "")
    End Try
 

DonManfred

Expert
Licensed User
Longtime User
i used this cod but not work!
And it does not give any error???

Note that reading the phonestate is a Dangerous permission. Are you requesting the permission using runtime permissions lib?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Wait For (ReadIMEI) Complete (Id As String)
   Log(Id)
End Sub


Sub ReadIMEI As ResumableSub
   Dim rp As RuntimePermissions
   rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
   Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
   If Result Then
       Dim p As PhoneId
       Return p.GetDeviceId
   Else
       Return "N/A"
   End If
End Sub

"Are you requesting the permission using runtime permissions lib?" no
https://www.b4x.com/search?query=runtime+permissions
 
Upvote 0
Top