uniqueidentifier - Android Unique Serial Number -
i developing android application targets android 4.0 (api 14) , above.
i looking serial number unique per device , persists ever (dies device, not change after factory resets).
i have found lots of results on web concerning unique identifiers android devices, little on android.os.build.serial number.
so far, eliminated use of android_id because might change after factory resets. eliminated use of imei because android device might non-phone. cannot use wifi or bluetooth mac address because device might not have such hardware and/or such mac addresses might not readable if hardware not enabled (based on found on web).
i believe might go android device serial number.
it accessible using android.os.build.serial (since added in api level 9 , not need additional permission).
my questions :
taking consideration application targets android 4.0 (api 14) , above, android.os.build.serial number android devices unique each device ?
currently, documentation of android.os.build.serial indicates : a hardware serial number, if available. alphanumeric only, case-insensitive. mean serial number might not available ?
what alternative meets conditions mentioned above ?
taking consideration application targets android 4.0 (api 14) , above, android.os.build.serial number android devices unique each device ?
according useful article in android developers blog, android.os.build.serial
should unique if available. article:
devices without telephony required report unique device id here; phones may also.
does mean serial number might not available ?
correct, may not available. notice "devices without telephony required...", devices without "telephony" (like wifi tablets) required supply serial
number, although phones still (like nexus 4).
documentation lacking on topic, wording it's possible "devices without telephony" required submit unique id, while phones submit 1 might not unique.
what alternative meets conditions mentioned above ?
for situation think best bet first check deviceid
(imei, or not) , if deviceid
doesn't exist fallback using android.os.build.serial
(since tablet) so:
public static string getdeviceid(context context) { final string deviceid = ((telephonymanager) context.getsystemservice(context.telephony_service)).getdeviceid(); if (deviceid != null) { return deviceid; } else { return android.os.build.serial; } }
keep in mind use deviceid
need permission android.permission.read_phone_state
.
so since app's minsdk 14, can safely use field android.os.build.serial
. , if assume devices without telephony provide unique ids in serial
think safe bet on getting unique device id (bar bugs of course).
Comments
Post a Comment