Reputation: 71
I'm implementing a Pseudo-Unique ID as shown below ATM and people say it won't be unique if user updates the OS. So does the Build class get impacted on a OS update? If so, how?
public static String getPsuedoUniqueID() {
String uniqueID = "35" +
(Build.BOARD.length() % 10)
+ (Build.BRAND.length() % 10)
+ (Build.CPU_ABI.length() % 10)
+ (Build.DEVICE.length() % 10)
+ (Build.MANUFACTURER.length() % 10)
+ (Build.MODEL.length() % 10)
+ (Build.PRODUCT.length() % 10);
String serial = null;
try {
serial = android.os.Build.class.getField("SERIAL").get(null).toString();
return new UUID(uniqueID.hashCode(), serial.hashCode()).toString();
} catch (Exception e) {
serial = "helloWorld";
}
return new UUID(uniqueID.hashCode(), serial.hashCode()).toString();
}
Upvotes: 0
Views: 271
Reputation: 71
Found the answer from this
In a scenario where a custom OS is implemented, that particular developer/team might follow a different approach to setting the values, (they might alter the values, e.g: for android.os.build.serial) So in a scenario where you decided to update to a custom OS there's a possibility that the Build class get impacted.
Upvotes: 0
Reputation: 93678
It won't be unique at all. For a given model of device, all of those lengths will be the same. So every user with the same model will be the same. At least- its quite possible it will have collisions even before then. Your idea is broken from the outset. Use one of the existing ids in Android. Or have them login and track by login.
Upvotes: 1