How to get a certification number (UniqueID) for an Android device on XE7

I need each phone (or tablet) to have its own identification code. Found a DeviceInfo project which gives

  1. Name OS
  2. OS type
  3. OS version

there is a code

procedure TDeviceInfoForm.btnGetDeviceInfoClick(Sender: TObject); var codename: string; begin codename := 'Unknown'; lbDeviceType.Text := Format('Device Type: %s', [JStringToString(TJBuild.JavaClass.MODEL)]); lbOSName.Text := Format('OS Name: %s', [JStringToString(TJBuild_VERSION.JavaClass.RELEASE)]); lbOSVersion.Text := Format('OS Version: %s', [JStringToString(TJBuild_VERSION.JavaClass.RELEASE)]); end; 

Can anyone have a practice in this? What fields can this be made of?

  • @metalurgus thanks for the answer, but is it possible to get Google Plus or another with the TJBuild class as I showed in the code? The main thing for me is that the serial number does not repeat and cannot be changed by a simple method. I need to protect the program. That the program would not work in offline copying another phone - Saidolim

2 answers 2

For Android there is no absolutely reliable way to identify a device. There is one regular method, but it returns a different ID after flashing it; it can be faked with the help of ROOT , on some devices it does not work at all. You can try to attach to the ID some equipment, for example, to the MAC-адрессу WIFI or BLUETOOTH , but I can not guarantee that they do not change. As practice shows, the most reliable way is to identify the user, not the device. Example - authorization via Google Plus , VK , Facebook , etc.

  • You can show a sample code to get the MAC address or other serial number of any equipment. I need it in Delphi, in java everything works out for me. - Saidolim
  • one
    @Saidolim With the permission of the author of the code I will leave the link here: fire-monkey.ru/topic/ ... I did not receive permission to copy part of the code, so I cannot issue a reply. I recommend to revise the binding policy, as advised by metalurgus. Consider the chinaphone factor - there all the identifiers can be left-handed (if not generally filled with zeros). - kami

Rummaged on the Internet, there is no single answer for offline applications. Everywhere, as @metalurgus said, you need to identify the user via the Internet.

But decided so

 implementation {$IFDEF ANDROID} uses androidapi.JNI.JavaTypes, Androidapi.Helpers, androidapi.JNI.Os; {$ENDIF} {$R *.fmx} {$R *.LgXhdpiPh.fmx ANDROID} {$IFDEF ANDROID} procedure TDeviceInfoForm.btnGetDeviceInfoClick(Sender: TObject); begin ListBox2.Items.Add(Format('Device Type: %s', [JStringToString(TJBuild.JavaClass.MODEL)])); ListBox2.Items.Add(Format('getRadioVersion: %s', [JStringToString(TJBuild.JavaClass.getRadioVersion)])); ListBox2.Items.Add(Format('BOARD: %s', [JStringToString(TJBuild.JavaClass.BOARD)])); ListBox2.Items.Add(Format('BOOTLOADER: %s', [JStringToString(TJBuild.JavaClass.BOOTLOADER)])); ListBox2.Items.Add(Format('BRAND: %s', [JStringToString(TJBuild.JavaClass.BRAND)])); ListBox2.Items.Add(Format('CPU_ABI: %s', [JStringToString(TJBuild.JavaClass.CPU_ABI)])); ListBox2.Items.Add(Format('CPU_ABI2: %s', [JStringToString(TJBuild.JavaClass.CPU_ABI2)])); ListBox2.Items.Add(Format('DEVICE: %s', [JStringToString(TJBuild.JavaClass.DEVICE)])); ListBox2.Items.Add(Format('DISPLAY: %s', [JStringToString(TJBuild.JavaClass.DISPLAY)])); ListBox2.Items.Add(Format('FINGERPRINT: %s', [JStringToString(TJBuild.JavaClass.FINGERPRINT)])); ListBox2.Items.Add(Format('HARDWARE: %s', [JStringToString(TJBuild.JavaClass.HARDWARE)])); ListBox2.Items.Add(Format('HOST: %s', [JStringToString(TJBuild.JavaClass.HOST)])); ListBox2.Items.Add(Format('ID: %s', [JStringToString(TJBuild.JavaClass.ID)])); ListBox2.Items.Add(Format('MANUFACTURER: %s', [JStringToString(TJBuild.JavaClass.MANUFACTURER)])); ListBox2.Items.Add(Format('MODEL: %s', [JStringToString(TJBuild.JavaClass.MODEL)])); ListBox2.Items.Add(Format('PRODUCT: %s', [JStringToString(TJBuild.JavaClass.PRODUCT)])); ListBox2.Items.Add(Format('RADIO: %s', [JStringToString(TJBuild.JavaClass.RADIO)])); ListBox2.Items.Add(Format('SERIAL: %s', [JStringToString(TJBuild.JavaClass.SERIAL)])); ListBox2.Items.Add(Format('TAGS: %s', [JStringToString(TJBuild.JavaClass.TAGS)])); ListBox2.Items.Add(Format('TIME: %s', [IntToStr(TJBuild.JavaClass.TIME)])); ListBox2.Items.Add(Format('&TYPE: %s', [JStringToString(TJBuild.JavaClass.&TYPE)])); ListBox2.Items.Add(Format('UNKNOWN: %s', [JStringToString(TJBuild.JavaClass.UNKNOWN)])); ListBox2.Items.Add(Format('USER: %s', [JStringToString(TJBuild.JavaClass.USER)])); ListBox2.Items.Add(Format('CODENAME: %s', [JStringToString(TJBuild_VERSION.JavaClass.CODENAME)])); ListBox2.Items.Add(Format('INCREMENTAL: %s', [JStringToString(TJBuild_VERSION.JavaClass.INCREMENTAL)])); ListBox2.Items.Add(Format('RELEASE: %s', [JStringToString(TJBuild_VERSION.JavaClass.RELEASE)])); ListBox2.Items.Add(Format('SDK: %s', [JStringToString(TJBuild_VERSION.JavaClass.SDK)])); ListBox2.Items.Add(Format('SDK_INT: %s', [IntToStr(TJBuild_VERSION.JavaClass.SDK_INT)])); end; {$ENDIF} 

there are fields like SERIAL, DISPLAY, MODEL, RELEASE.

How to get IMEI phone

 uses androidapi.JNI.Telephony, androidapi.JNI.Provider, androidapi.JNIBridge, androidapi.JNI.GraphicsContentViewText, FMX.Helpers.Android; ... var obj: JObject; tm: JTelephonyManager; identifier: String; begin obj := SharedActivityContext.getSystemService (TJContext.JavaClass.TELEPHONY_SERVICE); if obj <> nil then begin tm := TJTelephonyManager.Wrap((obj as ILocalObject).GetObjectID); if tm <> nil then identifier := JStringToString(tm.getDeviceId); end; ListBox2.Items.Add('identifier 1: '+identifier); if identifier = '' then identifier := JStringToString(TJSettings_Secure.JavaClass.getString (SharedActivity.getContentResolver, TJSettings_Secure.JavaClass.ANDROID_ID)); ListBox2.Items.Add('identifier 2: '+identifier); end; 

I decided to use them and create a key. then register via SMS who have no internet.

I took the code from here for IMEI from here

Thanks, @kami, for the advice. codes received, but according to the policy of this site code must be answered.