1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Read The IMEI Device ID With Delphi XE5

Discussion in 'Delphi Android And IOS' started by AdminDF, Apr 3, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Here is a code snippet which gets the Android device IMEI for you using the Android JNI. The IMEI (International Mobile Equipment Identity) is a unique device ID separate from your SIM card. Accessing the IMEI also requires that your app has the READ_PHONE_STATE permission to be able to access it. I’m not sure who wrote the original example code but on the Embarcadero forum Remy Lebeau posted this code snippet in October of 2013. Here is the full permission line for the Android manifest:

    Code:
    <uses-permission android:name=”android.permission.READ_PHONE_STATE” />
    And here is the code snippet:

    Code:
    uses
    Androidapi.JNI.Telephony, Androidapi.JNI.Provider ,
    Androidapi.JNIBridge, Androidapi.JNI.GraphicsContentViewText ,
    Androidapi.JNI.JavaTypes,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;
    if identifier = ” then
    identifier := JStringToString(TJSettings_Secure.JavaClass.getString(SharedActivity.getContentResolver,
    TJSettings_Secure.JavaClass.ANDROID_ID));
    
    end;
     

Share This Page