Tuesday, April 10, 2012

How to find Android Unique Device ID or UDID - Part 2

In the previous post
we had seen only how to get ANDROID_D.

Now We will see the Difference Between Android ID & Device ID of Android Phone

Android ID : 
ANDROID_ID is 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.(The value may change if a factory reset is performed on the device.)
Device ID :
Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.

Here is sample Code to get UDID

public class DemoActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {

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

    Log.d("ID", "Android ID: " + Secure.getString(getContentResolver(), Secure.ANDROID_ID));
    Log.d("ID", "Device ID : " + tm.getDeviceId());


For getting Device ID you have to set following permission in AndroidMenifest.xml

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

For getting ANDROID_ID you don't need to set any permission.

ANDROID_ID seems a good choice for a unique device identifier.


sonam jain said...

Thanks for sharing useful information we are provide best service.

Videocon Group Punjab telecom arm, Quadrant Televentures, today received permit from the DoT to launch pan-India Internet services.

Waled Mohamed said...

برنامج موارد بشرية

Waled Mohamed said...

شركات نقل عفش فى الرياض

Mr. Waled Mohamed said...

برنامج مقاولات