android gsf id生成,GSF ID KEY (google service framework id) as Android device unique identifier
I need to uniquely identify an Android device. I read about ANDROID_ID but it seems to have problems with Android 2.2. Then there are other identifiers related to TelephonyManager, but I reckon they d
I need to uniquely identify an Android device. I read about ANDROID_ID but it seems to have problems with Android 2.2. Then there are other identifiers related to TelephonyManager, but I reckon they don't work on tablets.
So, looking for something working on every device I stumbled upon the GSF ID KEY (google service framework id). Do you guys think this is a reliable and always working solution?
This is the code I found to retrieve the GSF ID KEY:
private static String getGsfAndroidId(Context context)
{
Uri URI = Uri.parse("content://com.google.android.gsf.gservices");
String ID_KEY = "android_id";
String params[] = {ID_KEY};
Cursor c = context.getContentResolver().query(URI, null, null, params, null);
if (!c.moveToFirst() || c.getColumnCount() < 2)
return null;
try
{
return Long.toHexString(Long.parseLong(c.getString(1)));
}
catch (NumberFormatException e)
{
return null;
}
}
更多推荐
所有评论(0)