From a native application how can we detect Google Glass verses a smart phone from code?
Moving correct answer to question:
boolean isRunningOnGlass() {
return "Google".equalsIgnoreCase(Build.MANUFACTURER) && Build.MODEL.startsWith("Glass");
}
Using the GDK, you could use:
(The model check may be good if a new model of Google Glas comes out.)
Another way of doing this would be to use the Build API:
http://developer.android.com/reference/android/os/Build.html
You can figure out your android app is running on which OS Build, Product, Device etc. by using the android.os.Build class.
Eg: You can detect if your app is running on google glass(API 19) like this:
Log Results
Similarly, for watches (API KITKAT_WATCH = 20).
I suspect that there will be an official way of getting this, but perhaps you could use the browser user-agent:
1) On Android, you can get the user-agent programmatically via: how to get the default HTTP USER AGENT from the android device?
2) The user-agent can change, of course, but at of July 2013 it is/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