Featured post

Marshmallow Features Point by Point

Android Runtime (“ART”) Improved application performance and lower memory overhead for faster  multi-tasking. Battery Doze...

Monday 2 February 2015

get unique Device id with hexaAndroidId

Use below function for UniqueID

String getDeviceID()
{
TelephonyManager telephonyManager = (TelephonyManager)  getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + phonyManager.getDeviceId();
tmSerial = "" + phonyManager.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());
Log.e("Device Id", deviceUuid.toString());
return deviceUuid.toString();
}

don't forget that you need permission to read the TelephonyManagerproperties, so add this to your manifest:

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

No comments:

Post a Comment