1

i want unique device id from android device. I want unique device id from android device how to get that one.

4 Answers4

1

yes you can get android device mac id which is known as unique identifier assigned to network interfaces for communications on the physical network segment this is a unique id for each device which cannot be changed however.

you can get it by WIFImanager in android

WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String MACAddress = wifiInfo.getMacAddress(); 

dont forget to add permission to your manifest file

<uses-permission android:name="android.permission.READ_PHONE_STATE"> </uses-permission>
raj
  • 2,088
  • 14
  • 23
1

I don't think there's any (perfect) way to do this. See link. If you just want to identify the user, you can generate one UUID and store it in your application's storage.

suitianshi
  • 3,300
  • 1
  • 17
  • 34
1

have created once class and use this in my app see pastie

its create unique ID and generate MD5 message as string of unique device ID

public String getUDID(Context c) {

    // Get some of the hardware information
    String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI
            + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST
            + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT
            + Build.TAGS + Build.TYPE + Build.USER;

    // Requires READ_PHONE_STATE
    TelephonyManager tm = (TelephonyManager) c
            .getSystemService(Context.TELEPHONY_SERVICE);

    // gets the imei (GSM) or MEID/ESN (CDMA)
       String imei = tm.getDeviceId();

      //gets the android-assigned id you can omit this because 
      //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.
    String androidId = Secure.getString(c.getContentResolver(),
            Secure.ANDROID_ID);

    // requires ACCESS_WIFI_STATE
    WifiManager wm = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);

    // gets the MAC address
    String mac = wm.getConnectionInfo().getMacAddress();

    // concatenate the string
    String fullHash = buildParams + imei + androidId + mac;

    return md5(fullHash);

}

md5(String fullHash) Function

public String md5(String toConvert) {

    String retVal = "";

    MessageDigest algorithm;
    try {
        algorithm = MessageDigest.getInstance("MD5");
        algorithm.reset();
        algorithm.update(toConvert.getBytes());
        byte messageDigest[] = algorithm.digest();
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < messageDigest.length; i++) {
            hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
        }
        retVal = hexString + "";
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return retVal;
}
MilapTank
  • 9,988
  • 7
  • 38
  • 53
0

It's really simple, actually..

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                    Secure.ANDROID_ID); 
SteBra
  • 4,188
  • 6
  • 37
  • 68