How to get glass serial number programmatically

How can I get a 14-digit alphanumeric (e.g. LGGXXXXXXXXXXX) Google Glass serial number programmatically. Could you give some examples.

+4
source share
1 answer

It looks like you can easily get Android Serial by extracting the value of android.os.Build.SERIAL

For instance:

Log.i(TAG, "Serial: "+android.os.Build.SERIAL); 

For Device Serial, it is more complex, but I was able to get it also using reflection:

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;
}
+5
source

Source: https://habr.com/ru/post/1536388/


All Articles