[Android] User Unique Identifier Research Report

1. Background

  • Background: Some of the minigames are sensitive. Product design needs to be displayed according to the list of users.
    There are two types of game visible lists, one is all games, and the other is non-sensitive games. Which list to display is determined according to the user's latitude. Since overseas cannot solve the problem of mobile phone numbers, log in by specifying the uniqueness of the user.
  • Technical positioning: primary/intermediate
  • Target group: product, development engineer
  • Overall idea: sort out the current android method of distinguishing user uniqueness and the advantages and disadvantages of implementation, for subsequent development and product selection.

2. The unique identifier of the mainstream

2.1 Device ID

This is a more traditional way to obtain the hardware ID of the device. Generally speaking, this type of unique identifier Device ID usually uses device hardware-related identifiers such as IMEI (International Mobile Equipment Identity) or MEID (Mobile Equipment Identifier).

  • The MEI is a unique 15-digit identifier primarily used to identify mobile phone devices. Each mobile phone device has a unique IMEI number, you can check the IMEI number of the device by dialing codes such as *#06#
  • MEID is an equipment identifier used in CDMA networks and is also a unique identifier consisting of 15 digits. Similar to IMEI, each CDMA device has a unique MEID number.
import android.content.Context;
import android.telephony.TelephonyManager;

// 获取设备IMEI号码
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = telephonyManager.getDeviceId();
需要注意的是,获取设备的IMEI或MEID号码需要相应的权限,如READ_PHONE_STATE权限。
获取Device ID的方式在不同的Android版本和设备上可能会有所不同,并且有一些限制和难度。

First of all, starting from Android 10, for non-system applications, there will be no direct access to device identifiers such as IMEI, MEID, and serial number. This is done for privacy and security reasons to protect users' personal information.

Second, different device manufacturers may have changed or restricted device identifiers in their customized Android systems. This may cause device identifiers such as IMEI or MEID to fail to be obtained on some devices.

2.2 Advertising ID

Android's Advertising ID (Advertising ID) is an identifier used for ad tracking and personalized advertising. It is an anonymous, non-personally identifiable identifier used to identify advertising-related information about devices and applications.

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;

// Get advertising ID
String advertisingId = null;
try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context); advertisingId = adInfo.getId(); } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { e. printStackTrace(); } It should be noted that obtaining the advertising ID depends on Google Play services, so the device must be installed with Google Play services to obtain the advertising ID normally. In addition, obtaining the advertising ID also requires corresponding permissions, such as ACCESS_NETWORK_STATE and INTERNET permissions.





2.3 Android ID(SSAID)

Android ID is the unique identifier of Android devices, which can be used to distinguish different devices. It is a 64-bit hexadecimal string, usually assigned to each device by the system. The Android ID is generated when the device is first booted and remains the same throughout the lifetime of the device, unless the device is reset or undergoes a system upgrade, etc. Generally, after Android 8.0, you can consider using ANDROID_ID instead of DeviceId.
To obtain the Android ID, you can use the Settings.Secure.ANDROID_ID constant provided by the Android system. The following is the sample code to get Android ID:

import android.provider.Settings;

String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);

It should be noted that the Android ID is not an absolutely reliable unique identifier. In some cases, a device may reset its Android ID, such as when the device is factory reset or undergoes a system refresh. Also, some devices may share the same Android ID, especially in a virtual machine or emulator.

2.4 UUID

A UUID is a 128-bit identifier used in computer systems to identify information. When UUID is generated according to a standard method, it is unique in practical applications and does not rely on registration and allocation by a central authority. The probability of UUID duplication is close to zero and can be ignored. Therefore, anyone can create and use UUIDs themselves, and they will almost certainly not duplicate existing identifiers.
Out-of-the-box behavior. Because we need to generate it manually, and each generation is different.
UUID.randomUUID().toString()
So it must be generated once and saved. This has a problem. If you save it to the internal storage of the application, it must be regenerated after uninstalling and reinstalling, so that it cannot be judged that it is the same device. So it is best to save it to an external storage to ensure that the last value can be read after uninstalling and reinstalling.
This is generally the most stable unless the file is manually deleted.

Guess you like

Origin blog.csdn.net/weixin_44002043/article/details/131440701