I would like to get unique ID from mobile phone.I know IMEI code is unique but it is too long for me.I only want to get most 4 unique digit in mobile phone information.
Asked
Active
Viewed 168 times
1
-
Should this be unique across all the devices who has installed your app? – rakesh kashyap Aug 30 '16 at 02:45
-
Use a hash function and IMEI as argument. However, I wonder why only 4 digits... – Diego Torres Milano Aug 30 '16 at 03:47
-
Even using a hash on one of the long unique numbers you're _guaranteed_ to have duplicates after the first 9999 devices. In reality, you may get a duplicate on the 2nd device. So you'll need an approach to handle collisions. – scottt Aug 30 '16 at 06:18
1 Answers
0
Android id is a unique String. You can use that.
Other way is using MAC. MAC address is also unique.It is 48bit lenghth. Use below method to get MAC.
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
String address = info.getMacAddress();
If you want exactly 4 digit, you can use any commonly available hash algorithm.

Ruthwik Warrier
- 84
- 9