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
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
TelephonyManager
properties, so add this to your manifest:<uses-permission android:name="android.permission.READ_PHONE_STATE" />
No comments:
Post a Comment