我该如何通过程序获取Google Glass的14位字母数字序列号(例如LGGXXXXXXXXXXX)?
看起来你可以通过获取值android.os.Build.SERIAL轻松获得Android串行号。
例如:
Log.i(TAG, "Serial: "+android.os.Build.SERIAL);
对于设备序列号,它更加复杂,但是通过反射也可以检索到:
public static String getGlassSerial(Context context) {
String prop="ro.serialno.glass";
String result=null;
try{
Class SystemProperties =
context.getClassLoader().loadClass("android.os.SystemProperties");
Class[] paramtypes=new Class[1];
paramtypes[0]=String.class;
Object[] paramvalues=new Object[1];
paramvalues[0]=new String(prop);
Method get=SystemProperties.getMethod("get", paramtypes);
result=(String) get.invoke(SystemProperties, paramvalues);
} catch(Exception e) {
result=null;
}
return result;
}