如何以编程方式获取Glass序列号

Sha*_*sad 3 java android google-glass

如何以编程方式获取Google Glass的14个字符的字母数字(如LGGXXXXXXXXXXX)序列号.你能举个例子吗?

are*_*ier 5

看起来你可以通过检索值android.os.Build.SERIAL轻松获得Android Serial

例如:

Log.i(TAG, "Serial: "+android.os.Build.SERIAL); 
Run Code Online (Sandbox Code Playgroud)

对于设备序列,它更复杂,但我也能够使用反射检索它:

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;
}
Run Code Online (Sandbox Code Playgroud)