tags:

views:

150

answers:

3
+1  Q: 

Android unique id

How do I get an unique id from an android phone?? Whenever i try to get the unique id from the phone as a string it always shows "android id" and no other unique hex values how do i get that one?

This is the code I use to get the id until now:

String id=Settings.Secure.getString(contentResolver,Settings.Secure.ANDROID_ID);
Log.i("Android is is:",id);

the output which i get is like this in my log cat:

Android id is: android id

i am using nexus one for testing.

how can i get that unique hex id?

+1  A: 
((TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();

with manifest

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

Edit:

Here is some interesting reading about the android id:

How to set the Android ID

Android ID Requires Market Login

Try setting it to something other than 'android id' and see if you read the new value.

drawnonward
Thanks for your reply but i want 32 bit unique id in getDeviceID() i only get 15 character so how can i get 32 bit HMAC MD5 id of android device ?
jaimin
+1  A: 

Wireless MAC address is more unique than IMEI, because the later gets spoofed on stolen devices. Drawback is that it only works on WiFi enabled devices. WifiInfo

ognian