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.
Pingback: My Homepage