Hello everyone..

I have shown one way to get the deviceID in android in this post.
Here are some other ways by which you can get the unique device ID of an android device.
First Method…

String deviceId = Settings.System.getString(getContentResolver(),Settings.System.ANDROID_ID);

Second Method

String deviceId = Secure.getString(this.getContext().getContentResolver(), Secure.ANDROID_ID);

Third Method

 final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, tmPhone, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();

Make sure to add this permission in your AndroidManifest file

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

These codes may depend on your SDK version and the type of the device manufacturer. So try one by one.

 

One Comment

  1. Pingback: My Homepage

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.