How can I get the 14 character alphanumeric(like LGGXXXXXXXXXXX) serial number of Google Glass programmatically?
            Asked
            
        
        
            Active
            
        
            Viewed 1,027 times
        
    3
            
            
        - 
                    3What a reason for downvote ? Seems legal question to me. – Lucifer Apr 14 '14 at 06:10
- 
                    Actually I need the id for making a unique communication channel between glass and server. – Shankar Prasad Apr 14 '14 at 06:24
- 
                    How about IMEI ? Its unique. – Lucifer Apr 14 '14 at 06:26
- 
                    Possible duplicate: http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id – Morrison Chang Apr 14 '14 at 06:29
- 
                    I have used.... TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.getDeviceId();...but it gives null value. – Shankar Prasad Apr 14 '14 at 06:30
- 
                    Did you try this [answer](http://stackoverflow.com/a/2785493/3330969) ? – Lucifer Apr 14 '14 at 06:43
- 
                    Thanks @Morrison Chang. But I am looking for serial number like LGGXXXXXXXXXXX, which is written on the box of glass or this unique number would be visible after Bluetooth connectivity with Android phone/tab via MyGlass app. – Shankar Prasad Apr 14 '14 at 06:46
- 
                    Yes @Kedarnath it gives Android OS unique id, I believe its not available for end user, only developer can access it via coding. I need that serial number because that is known by both end user as well as developer. – Shankar Prasad Apr 14 '14 at 06:51
- 
                    Did you check the "about phone"->"Status" option in real device ? – Lucifer Apr 14 '14 at 06:53
- 
                    Thanks @Kedarnath but I am looking for Glass serial number not Android phone device id. – Shankar Prasad Apr 14 '14 at 06:57
- 
                    Ha ha ha... I just forgot that it is google-glass not a phone :P – Lucifer Apr 14 '14 at 06:59
- 
                    @Kedarnath Google Glass does not have IMEI since it also does not have GSM hardware. – tasomaniac Jul 20 '14 at 20:38
1 Answers
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
- 
                    Thanks, it gives Android OS serial number but I am looking for Glass hardware ID that is visible in MyGlass Android application used to setup Glass. – Shankar Prasad May 14 '14 at 12:36
- 
                    after a bit of hacking I was able to find a way to retrieve the device serial too. I will update my answer. – aregnier May 18 '14 at 11:51
- 
                    Yeah I am able to get device serial. This code is working fine for me. Thanks. – Shankar Prasad May 28 '14 at 04:49
- 
                    Do you know if it still works on google glass with latest XE release? – andrea.rinaldi Oct 24 '14 at 14:27
 
    