How do I get device serial number under Android 9 and newer using Delphi?


I know that for earlier Android versions this is done using TJBuild.JavaClass.SERIAL. Starting with Android 9 SERIAL method is expected to return “UNKNOWN” string and so I need to use the new getSerial method, but it doesn’t (presumably, yet) exist in TJBuild class.

I’ve looked around for some code samples but haven’t found any and I’m not good at converting Java code into Delphi.

I’m using Delphi 10.2 Tokyo.

Code for using SERIAL method:

uses Androidapi.Helpers, Androidapi.JNI.Os;

function GetSerial: string;
Result := JStringToString (TJBuild.JavaClass.SERIAL);

Comments are closed.