3

How can I get the 14 character alphanumeric(like LGGXXXXXXXXXXX) serial number of Google Glass programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Shankar Prasad
  • 405
  • 6
  • 17

1 Answers1

5

Looks like you can get the Android Serial easily by retrieving the value android.os.Build.SERIAL

For example:

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

For the Device Serial it is more complex, but I was able to retrieve it too 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;
}
aregnier
  • 1,574
  • 2
  • 14
  • 19