Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Unique ID of Android Device? [duplicate]

Tags:

android

I have htc one b model android phone. I want to know my device ID. I do not know how could I finding out my device ID .

like image 566
user3736827 Avatar asked Jun 17 '14 11:06

user3736827


2 Answers

Try this :

    String deviceId = Secure.getString(this.getContentResolver(),
            Secure.ANDROID_ID);
    Toast.makeText(this, deviceId, Toast.LENGTH_SHORT).show();

android.provider.Settings.Secure.ANDROID_ID

A 64-bit number (as a hex string) that is randomly generated on the device’s first boot and should remain constant for the lifetime of the device.

Source Link : http://blog.vogella.com/2011/04/11/android-unique-identifier/

Note : The value may change if a factory reset is performed on the device.

like image 85
Siddharth_Vyas Avatar answered Nov 18 '22 19:11

Siddharth_Vyas


Try this:

TelephonyManager TM = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

// IMEI No.
String imeiNo = TM.getDeviceId();

// IMSI No.
String imsiNo = TM.getSubscriberId();

// SIM Serial No.
String simSerialNo  = TM.getSimSerialNumber();

// Android Unique ID
String androidId = Settings.Secure.getString(this.getContentResolver(),Settings.Secure.ANDROID_ID);

Don't forget to add

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

to your manifest file.

like image 9
Y.S Avatar answered Nov 18 '22 21:11

Y.S