Created
          October 6, 2011 13:29 
        
      - 
      
- 
        Save gipi/1267393 to your computer and use it in GitHub Desktop. 
    Retrieve an identification ID from an android device
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id | |
| final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE); | |
| final String tmDevice, tmSerial, tmPhone, androidId; | |
| tmDevice = "" + tm.getDeviceId(); | |
| tmSerial = "" + tm.getSimSerialNumber(); | |
| androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); | |
| UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode()); | |
| String deviceId = deviceUuid.toString(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment