I think many of you thought which is best to retrieve from the Android Device, so that you can be sure the device will not trick you and the identifier you asked is unique and unchangeable.
For example we can get the IMEI code but users would became suspicious because you will need to set a permission to use this, and beside this IMEI have only phones, not tablets.
You may choose to retrive ANDROID_ID with the following code:
String deviceId = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID);
But this is documented to be changeable at the factory reset and unpredictive changeable on rooted phones.
Other option would be to get a Serial Number:
TelephonyManager manager= (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE); String serial= manager.getDeviceId();
This will need permission: android.permission.READ_PHONE_STATE
getDeviceID() will return the MDN or MEID of the device depending on which radio the phone uses (GSM or CDMA).
As you already guess this option have the same disadvantage(DON’ T WORK FOR TABLETS ).
We have one last solution and maybe it’ s the best, since over 95% of Android Powered Devices have a wireless card.
So we will retrieve the MAC address:
WifiManager wimanager = (WifiManager)getSystemService(Context.WIFI_SERVICE); String address= wimanager.getConnectionInfo().getMacAddress();
This will need permission: android.permission.ACCESS_WIFI_STATE
WiFi MAC address can be easily faked on rooted phones, so we have another unique serial number on Bluetooth.
Code for retrieving Bluetooth unique identifier:
BluetoothAdapter btAdapt= null; btAdapt = BluetoothAdapter.getDefaultAdapter(); String address= btAdapt.getAddress();
This code will need permission: android.permission.BLUETOOTH