Android device Identification-no perfect solution-only trade-offs

Source: Internet
Author: User

This article links http://blog.csdn.net/xiaodongrush/article/details/28864845

1. Several commonly used device identification code

Imei,sim card serial number, WiFi module MAC address, android_id

Telephonymanager Telephonymanager = (telephonymanager) this.getsystemservice (Context.telephony_service); String IMEI = Telephonymanager.getdeviceid (); String Simno = Telephonymanager.getsimserialnumber (); Wifimanager wm = (Wifimanager) getsystemservice (Context.wifi_service); String wifiaddress = Wm.getconnectioninfo (). getmacaddress (); String Androidid = secure.getstring (Getcontentresolver (), secure.android_id);
IMEI can be directly rewritten with software, duplication is unavoidable, the standard is 15 digits, some devices, even this standard is not guaranteed. The IMEI corresponds to each phone, and the pad has no IMEI. In addition, Xiaomi 2 found that if you do not trust an app, then the app will not read the IMEI, that is, read the result is null. The IMEI is how not reliable.
Pad does not have a SIM card, naturally there is no SIM card serial number, dual SIM phone will also have two SIM card serial number. Pad also troublesome, no IMEI, no SIM card serial number.
Some phones or devices do not have a WiFi module and the MAC address cannot be read. A mobile device has WiFi, this should be there, but there is no guarantee not to repeat.
android_id after each restore of the Factory mode, will be regenerated, and the other individual phone bugs, the resulting android_id are the same. Instead of giving the system an ID, you might as well generate the ID yourself.

2. Combinations of common identities

    1. If the IMEI is not empty, return the IMEI, otherwise, go to 2    2. If the SIM card serial number is not empty, return the serial number, otherwise, go to 3    3. If the MAC address is not empty, MD5 (mac+ "mac_address"), otherwise enter 4    4. If android_id is not empty, return to android_id, otherwise enter 5    5. Return to "Invalid_imei"

If it is the statistics app installs the general use above these methods to be possible. This will only reduce the number of devices that are counted, not more.

3. What if you want to implement a device management function like this?

This requires that the identity of each device cannot be duplicated, so using the method above is not possible. Use UUID to process and persist to sharedpreference and SD cards so that no new identities will be regenerated as long as the app and files are not killed at the same time.

Device ID Generation

1. If the IMEI is not empty and the length is equal to 15, then DeviceID = Android-imei-uuid-timestamp. otherwise into 2. 2. DeviceID = Android-uuid-timestamp

Device ID Read

1. If from sharedpreference, read to DeviceID, store the ID on the SD card, return the change ID, otherwise enter 22. If the SD card is read to DeviceID, then store the ID to sharedpreference, return the ID, or enter 33. Generate DeviceID, store to SD card and sharedpreference

4. Reference Articles

Http://android-developers.blogspot.com/2011/03/identifying-app-installations.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.