Skip to content

Instantly share code, notes, and snippets.

@Mistobaan
Created November 18, 2013 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mistobaan/7521825 to your computer and use it in GitHub Desktop.
Save Mistobaan/7521825 to your computer and use it in GitHub Desktop.
Capturing an image with google Glasses
public void onClick(View v) {
Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(captureIntent, REQUEST_IMAGE_CAPTURE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK
&& null != data) {
Bundle b = data.getExtras();
Set<String> keys = b.keySet();
for (String key: keys)
{
Object o = b.get(key);
Log.d(key,o.getClass().getName());
}
String photoPath = data.getExtras().getString("picture_file_path");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = BitmapFactory.decodeFile(photoPath, options);
image.setImageBitmap(bitmap);
// Following did not work
// bitmap = (Bitmap) data.getExtras().get("data");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment