I need to register user devices on server with an unique identifier that be a constant value and doesn't change in the future.
I can't find a good solution to get unique id from all devices (with/without simcard).
Secure.ANDROID_ID: Secure.ANDROID_ID is not unique and can be null or change on factory reset.
String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
IMEI: IMEI is dependent on the Simcard slot of the device, so it is not possible to get the IMEI for the devices that do not use Simcard.
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tManager.getDeviceId();
WLAN MAC Address: If device doesn’t have wifi hardware then it returns null MAC address. and user can change the device mac address.
WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();
Bluetooth Address string:If device hasn’t bluetooth hardware then it returns null.
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_bluetoothAdd = m_BluetoothAdapter.getAddress();
Instance id: instance_id will change when user uninstalls and reinstalls app. and it's not a constant value.
Do you have any idea to get a unique id from all Android devices (with/without simcard, Bluetooth, ...) that really be unique, cannot be null and doesn't change after uninstall/reinstall app?
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.
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.
Use UUID UUID. randomUUID() method generates an unique identifier for a specific installation. You have just to store that value and your user will be identified at the next launch of your application.
All smartphones and tablets are identified by a unique device ID. The Android unique device ID is called the Android Advertising ID (AAID). It's an anonymized string of numbers and letters generated for the device upon initial setup. None of the user's personal information is included in an Android ID.
I found that Secure.ANDROID_ID is the best choice. This is a 64-bit quantity that is generated and stored when the device first boots. But it resets on device factory reset.
there are some reports that shows some devices has same Secure.ANDROID_ID on all instances.
we can add extra items (like sim serial, GCM instance id or ...) to the Secure.ANDROID_ID and generate new unique fingerprint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With