Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get android device Unique ID? [duplicate]

Tags:

android

Possible Duplicate:
Is there a unique Android device ID?

I used below code to get android device IMEI and How can I change below code to get android device Unique ID.

String getDeviceID1(TelephonyManager phonyManager){
    String id = phonyManager.getDeviceId();
    if (id == null){
        id = "not available";
    }
    int phoneType = phonyManager.getPhoneType();
    switch(phoneType){
        case TelephonyManager.PHONE_TYPE_NONE:
            return "" + id;

        case TelephonyManager.PHONE_TYPE_GSM:
            return "" + id;

        case TelephonyManager.PHONE_TYPE_CDMA:
            return "" + id;

        /*
        *  for API Level 11 or above
        *  case TelephonyManager.PHONE_TYPE_SIP:
        *   return "SIP";
        */

        default:
            return "" + id;
    }

    //I used to show IMEI 

    TextView textDeviceID = (TextView)findViewById(R.id.deviceid);
    //retrieve a reference to an instance of TelephonyManager
    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    textDeviceID.setText(getDeviceID1(telephonyManager));
}
like image 626
ArnoHlaMoe Avatar asked Aug 30 '12 05:08

ArnoHlaMoe


People also ask

How can I get unique ID of my Android phone?

Settings. Secure#ANDROID_ID returns the Android ID as an unique for each user 64-bit hex string. It's known to be null sometimes, it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone.

Is device ID unique?

A device ID is a unique, anonymized string of numbers and letters that identifies every individual smartphone or tablet in the world. It is stored on the mobile device and can be retrieved by any app that is downloaded and installed.

Can device ID be changed?

No, Device id remains constant.

How can I track my device ID?

Finding your device ID is straightforward whether you have an Android or an Apple device. For an Android enter “*#*#8255#*#*” into the keypad. As soon as you type the last digit the GTalk service monitor device will pop up where you will be able to see your device ID.


1 Answers

In Android, you can get three different Unique Ids.

  • IMEI ( which you have in your code already )

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String id =  (getDeviceID1(telephonyManager));
    
  • Device ID

    String android_id = Secure.getString(getContext().getContentResolver(),
                                                    Secure.ANDROID_ID); 
    
  • Bluetooth Address ( this will also be unique for each device )

    private BluetoothAdapter mBtAdapter;
    
    // Get the local Bluetooth adapter
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    String deviceMacAddress = mBtAdapter.getAddress();
    
like image 191
Lucifer Avatar answered Sep 30 '22 20:09

Lucifer