AHMED
AHMED

Reputation: 41

Unique Identifier for Android Device - Unavailable

I want to use a Unique identifier for my library as multiple app in the same phone can utilise same unique ID. For example Android Phone A - can have 3 apps in the Phone A with same library integrated with all 3 apps, so all 3 must use the same ID to identify this as 1 device, rather than having 3 different IDs. Additionally, this app can be released from 3 different build machines and the app package names might not be known always.

Devices tested: Samsung - Android 9, 10 and 11 MI - Android 9, 10 and 11 Huawei- Android 9 and 10

Upvotes: 4

Views: 5313

Answers (1)

Taranmeet Singh
Taranmeet Singh

Reputation: 1239

As defined by Android Best Practices you should not use any Hardware ID like IMEI, MAC Address etc.

That leaves you with either Google Ad ID(GUID) or Firebase Installation Id(FID) or you can create your own unique ID solution which are all software generated ID's which can be reset by the user by things like factory reset.

If you are fine with the fact that some small sample size of users will still be able to reset the device ID which is expected among current companies then you can use the Account Manager API to share the ID generated by application. Although this is used to create a single login for all applications of a company by sharing the tokens and user name you can repurpose the Account Manager API for sharing the unique ID. Whenever an application is installed write your unique ID to Account Manager and when a new application is installed check if this ID already exists if it does then use the same else create a new one and write to Account Manager.

Still there will be some use-cases where the same phone will be represented by a new ID but such exceptional cases will be fractional and IMHO can be overlooked.

Upvotes: 4

Related Questions