Malluce
Malluce

Reputation: 141

Trigger Camera on Google Glass

I want to have a way to trigger the camera on Google Glass right after I get in (e.g., "Ok Glass", "App", ) but I cannot find any similar examples online. Any idea how to trigger this? Also, currently when I try to create a new Android project it will be the default Hello World, is there a template for Google Glass?

Upvotes: 1

Views: 683

Answers (3)

Rakesh
Rakesh

Reputation: 2770

On Ok glass you can write like -

    String fileUri ="file:///mnt/sdcard/Pictures/" ;

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // file:///mnt/sdcard/Pictures/MyCameraApp/IMG_20130812_105617.jpg

    startActivityForResult(intent, TAKE_PICTURE_REQUEST);

Then you have to call -

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

    super.onActivityResult(requestCode, resultCode, data);
}

It will work.

Upvotes: 1

Darren
Darren

Reputation: 1427

You can use my sample Camera Snapshot on GitHub. It does exactly what you're asking.

Here it is: https://github.com/dazza222/GlassCameraSnapshot

Upvotes: 0

Tony Allevato
Tony Allevato

Reputation: 6429

If you want to launch the built-in camera application immediately at the beginning of your application, you can call startActivityForResult with an intent whose action is MediaStore.ACTION_IMAGE_CAPTURE inside your initial activity's onCreate method. (But note the differences between Android and Glass with respect to how the captured photo is returned; see the Glass Camera class Javadoc for more details.)

Eclipse and Android Studio do not currently have any special support to generate Glass projects out of the box.

Upvotes: 0

Related Questions