ANDROID – 获取持久性设备标识符(UUID)

在卸载并重新安装应用程序后,我需要一个设备标识符.我知道UUID类为该方法提供了一个标识符

String uniqueID = UUID.randomUUID().toString();

但Android指南尚不清楚其范围和持久性.在下一段中它说:

The Android Operating system offers a number of IDs with different behavior characteristics and which ID you should use depends on how those following characteristics work with your use-case. But these characteristics also come with privacy implications so it’s important to understand how these characteristics play together.

Scope

Identifier scope explains which systems can access the identifier. Android identifier scope generally comes in three flavors:

Single app. the ID is internal to the app and not accessible to other apps.

Group of apps – the ID is accessible to a pre-defined group of related apps.

Device – the ID is accessible to all apps installed on the device.
The wider the scope granted to an identifier, the greater the risk of it being used for tracking purposes. Conversely, if an identifier can only be accessed by a single app instance, it can’t be used to track a device across transactions in different apps.

Resettability and persistence

Resettability and persistence define the lifespan of the identifier and explain how it can be reset. Common reset triggers are: in-app resets, resets via System Settings, resets on launch, and resets on installation. Android Identifiers can have varying lifespans, but the lifespan is usually related to how the ID is reset:

Session-only – a new ID is used every time the user restarts the app.

Install-reset – a new ID is used every time user uninstalls and reinstalls the app.

FDR-reset – a new ID is used every time the user factory-resets the device.

FDR-persistent – the ID survives factory reset.

Resettability gives users the ability to create a new ID that is disassociated from any existing profile information. This is important because the longer, and more reliably, an identifier persists (e.g. across factory resets etc.), the greater the risk that the user may be subjected to long-term tracking. If the identifier is reset upon app reinstall, this reduces the persistence and provides a means for the ID to be reset, even if there is no explicit user control to reset it from within the app or the System Settings.

但我不知道如何获取这些标识符,选择我的范围和持久性.
谢谢

最佳答案 我用这个:

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

看这个帖子:
Is there a unique Android device ID?

点赞