Auto Glass Detection

From our own application, how can we find that Google Glass is a smartphone from code?

Moving the correct answer to the question:

boolean isRunningOnGlass() { return "Google".equalsIgnoreCase(Build.MANUFACTURER) && Build.MODEL.startsWith("Glass"); } 
+7
google-glass google-gdk
source share
4 answers

Another way to do this is to use the build API:

http://developer.android.com/reference/android/os/Build.html

+6
source share

Using GDK, you can use:

  boolean isRunningOnGlass() { return "Google".equalsIgnoreCase(Build.MANUFACTURER) && Build.MODEL.startsWith("Glass"); } 

(Model validation may be good if a new Google Glas model appears.)

+4
source share

I suspect there will be an official way to get this, but maybe you can use the browser user agent:

1) On Android, you can get the software agent through how to get the HTTP USER HTTP USER from the Android device.

2) The user agent may, of course, change, but in July 2013 he was / was:

Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; Glass 1 Build/IMM76L; XE7) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

0
source share

You can find out if your Android application is running on which the OS, product, device, etc. is built using the android.os.Build class.

For example: you can determine if your application runs on Google glass (API 19), for example:

 if(Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT){ Log.e("SDK_INT",""+Build.VERSION.SDK_INT); Log.e("MODEL",""+Build.MODEL); Log.e("DEVICE",""+Build.DEVICE); Log.e("TYPE",""+Build.TYPE); Log.e("HARDWARE",""+Build.HARDWARE); Log.e("BRAND",""+Build.BRAND); Log.e("DISPLAY",""+Build.DISPLAY); Log.e("MANUFACTURER",""+Build.MANUFACTURER); Log.e("PRODUCT",""+Build.PRODUCT); if (isGlass()){ Log.e("isGlass","True"); } } else { Log.e("Other",""+Build.VERSION.SDK_INT); } boolean isGlass(){return"Google".equalsIgnoreCase(Build.MANUFACTURER)&&Build.MODEL.startsWith("Glass"); } 

Magazine Results

 09-13 17:58:42.835 24240-24240/com.example.myxlab.beyondartest E/SDK_INT: 19 09-13 17:58:42.835 24240-24240/com.example.myxlab.beyondartest E/MODEL: Glass 1 09-13 17:58:42.835 24240-24240/com.example.myxlab.beyondartest E/DEVICE: glass-1 

Similarly, for hours (API KITKAT_WATCH = 20).

0
source share

All Articles