Dim JV As JavaObject
JV.InitializeContext
Dim Result As String
Dim alist As List
alist.Initialize
alist.AddAll(Array As String("ril.serialnumber","ro.serialno"))
Dim str,K As String
For i = 0 To alist.Size-1
K=alist.Get(i)
str = JV.RunMethod("gMS" ,Array(K))
If str.Length>4 Then
If (str <> "00000000000") And (str <> "0123456789ABCDEF") Then
Result = str
Exit
End If
End If
Next
Return(Result)
Since Android Q using Build.getSerial() gets a bit more complicated by requiring:
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE (which can only be acquired by system apps), or for the calling package to be the device or profile owner and have the READ_PHONE_STATE permission. This means most apps won't be able to uses this feature. See the Android Q announcement from Google.
It works if your app is a Systemapp or the Deviceowner app (kiosk mode).
As a normal app you probably do not get the permission needed. At least not in Android 7.1+
It works if your app is a Systemapp or the Deviceowner app (kiosk mode).
As a normal app you probably do not get the permission needed. At least not in Android 7.1+