Thursday, September 20, 2012

how to get a device id in android phone


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

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

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


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

No comments:

Post a Comment