'Private NativeMe As JavaObject i have declared in process_Global
Sub GetDeviceId As String
Dim id As String
Dim r As Reflector
Dim Api As Int
Dim pi As PhoneId
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
If Api < 9 Then
'Old device
id= pi.GetDeviceId
Else if (Api >=9) And (Api < 26) Then
id= r.GetStaticField("android.os.Build", "SERIAL")
Else If Api >= 26 Then
id= NativeMe.RunMethod("getSerialNew", Null)
End If
If id.ToLowerCase = "unknown" Then
id= pi.GetDeviceId
End If
Return id
End Sub
#If Java
import java.lang.reflect.Method;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
/**
* Gets serial New.
*
* @return the serial
*/
public String getSerialNew() {
String result = initialVal;
try {
result = Build.getSerial();
} catch (Exception e) {
e.printStackTrace();
}
if (result == null || result.length() == 0) {
result = initialVal;
}
return result;
}
#End If