Google Glass Camera Snapshot - sample app and utility class (current as of XE11)
This app provides a utility class, GlassSnapshotActivity, that you can pull into your Glass project if you want to take a snapshot.
I created this utility class as I have a number of apps I'm working on that all require taking a snapshot quickly.
Calling the built-in camera activity didn't work all that well for me, as it took too long to take the snapshot, but also it creates a "Tap for options" step after the snapshot is taken, that I didn't want to use. I just wanted a class that took the picture and returned immediately. Also, the built-in activity took 5-10 seconds most of the time to return. This may improve in future releases. Also, a lot of the existing Camera examples online don't show how to acquire the camera for Glass. In the current release, if you use a Voice Trigger in your app, you may not get hold of the camera on the first call to Camera.open() so this Activity tries again and gives up after a specified period of time.
The MainActivity class shows how to call the GlassSnapshotActivity. It uses the Vocie Trigger "Test the camera." You specify the fileName that you want your snapshot saved to in your intent extras, as well as the width and height of the images, and how long you're willing to wait for the camera. On return from the Activity, you can read the image from the specified location.
Have fun. Feel free to drop me a line to suggest improvements, bug fixes and great places for coffee in NYC.