How to get the serial number of a mobile device?
I need the solution in delphi, firemonkey that works on both Android and iOS.
How to get the serial number of a mobile device?
I need the solution in delphi, firemonkey that works on both Android and iOS.
Android solution.
In Delphi I have no idea, but you can search the native android classes, as if it were in Java (I believe) and try to do something similar.
No java:
android.telephony.TelephonyManager.getDeviceId()
This code snippet will return a string with device ID (IMEI in GSM and MEID in CDMA).
For this to work, you must use the permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
For more details, click here !
getDeviceId ()
Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.
Source: link
Note that this method is deprecated in API level 26.
To get the IMEI, on Android, you can try the method below:
TelephonyManager tm = (TelephonyManager)
getSystemService(this.TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String imei = telephonyMgr.getImei();
} else {
String imei = telephonyMgr.getDeviceId();
}
Note that in some cases, Device ID
may change. Unlike IMEI, which is always unique.