0

I'm trying to get a picture, but with my code, is neccesary to confirm the image through "Tap" gesture.

Here is my code:

private void takePicture() {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, TAKE_PICTURE_REQUEST);
    }

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == TAKE_PICTURE_REQUEST && resultCode == RESULT_OK) {
            String thumbnailPath = data.getStringExtra(Intents.EXTRA_THUMBNAIL_FILE_PATH);
            String picturePath = data.getStringExtra(Intents.EXTRA_PICTURE_FILE_PATH);

            processPictureWhenReady(picturePath);
            // TODO: Show the thumbnail to the user while the full picture is being
            // processed.
        }
        else{
            takePicture();
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

I have see this post:

Is it possible to take a photo using Google Glass without "tap to accept"?

But I can't get the picture without Tap. Is there any example?

Thanks!

Community
  • 1
  • 1
adlagar
  • 877
  • 10
  • 31

1 Answers1

0

For this you need to add a mechanism that would enable the gesture detection. In your case it is the TAP gesture. I would recommend putting this piece of code in your takePicture() method:

 @Override
    public boolean onKeyDown(int keycode, KeyEvent event) {
        if (keycode == KeyEvent.KEYCODE_DPAD_CENTER) {
            // user tapped touchpad, do something
            return true;
        }
        ...
        return super.onKeyDown(keycode, event);
    }

This would enable you to take picture only when you tap on the Glass and hence confirm. For more details please take a look at this document.

AniV
  • 3,997
  • 1
  • 12
  • 17