Prior to Android 10, it was permissible to get the IMEI number from the TelephonyManager
. This is no longer allowed except for "special" apps. Various Java answers on StackOverflow recommend getting the ANDROID_ID
instead. The code for that is included below. I would appreciate some help in translating this Java code to Delphi. Thanks
if TJBuild_VERSION.JavaClass.SDK_INT >= 29 then
begin
{$ifdef JAVA}
deviceId = Settings.Secure.getString(
context.getContentResolver(),
Settings.Secure.ANDROID_ID);
{$endif}
end
else
begin
TelephonyManager := TJTelephonyManager.Create;
IMEI := JStringToString(TelephonyManager.getIMEI);
end;