I was working on an app (server-android client) that allow user to sign in from multiple android devices. When user logged in on a device, that device will be registered on server side, but I don't know how to avoid duplicate, so I was wondering that are there any chances to uniquely identify an android device? I think Google Play and Facebook can do that.
            Asked
            
        
        
            Active
            
        
            Viewed 2.1k times
        
    2 Answers
8
            
            
        There are several options available, but there is no 100% guarantee that they will always work. See the android developer blog post: http://android-developers.blogspot.in/2011/03/identifying-app-installations.html
Best method mentioned is Settings.Secure.ANDROID_ID
 
    
    
        Aman Gautam
        
- 3,549
- 2
- 21
- 25
- 
                    https://stackoverflow.com/a/55977643/3906926 – Waheed Nazir May 03 '19 at 22:12
2
            
            
        You can check the IMEI or MAC address of the device.
for IMEI
TelephonyManager.getDeviceId will work
for MAC
WifiInfo.getMacAddress will work
 
    
    
        Bugs Happen
        
- 2,169
- 4
- 33
- 59
 
    
    
        stinepike
        
- 54,068
- 14
- 92
- 112
- 
                    
- 
                    1@StinePike I was using the imei. If users use this app https://play.google.com/store/apps/details?id=com.lbe.parallel.intl&referrer=af_tranid%3DPRiStLWOu5urVvBj5RutIA%26pid%3DPSwebsite then we will get wrong imei. – Prashanth Debbadwar Feb 15 '17 at 06:35
- 
                    2Just a note taken from Android official site: `It is generally not recommended to use MAC address for any form of user identification. As a result, as of Android M, local device MAC addresses (for example, Wifi and Bluetooth) are not available via third party APIs. The WifiInfo.getMacAddress() method and the BluetoothAdapter.getDefaultAdapter().getAddress() method will both return 02:00:00:00:00:00`. – Ankit Shubham Jul 19 '17 at 10:52
- 
                    MAC Address can be fetched through NetworkInterface.getNetworkInterfaces() or DevicePolicyManager. – Stephen M -on strike- Apr 03 '18 at 19:23
- 
                    4
