0

I have this working code for saving a spoken text as an array of Strings:

 @Override
    protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
        if (requestCode == SPEECH_REQUEST && resultCode == RESULT_OK) {
            List<String> results = data.getStringArrayListExtra(
                    RecognizerIntent.EXTRA_RESULTS);
            spokenText = results.get(0);
            if(strArray.length>arrayKey){
                strArray[arrayKey]=spokenText;
                arrayKey++;
            }
        }

I want to do exactly the same not only with spoken text, but with photos and videos I just took. For example, I take photos using this:

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

How can I store photos and videos I just captured with the glasses each time after I take them into an array? Obviously, I need to add another "if" case to onActivityResult(), but I would like to know what is the parallel of the SPEECH_REQUEST in photos and videos.

Many thanks!

Roi Bueno
  • 99
  • 10

1 Answers1

0

You should add anothers "if" in onActivityResult for image and videos.

These should be like:

if (requestCode == TAKE_VIDEO_REQUEST && resultCode == RESULT_OK) 
        {
            mVideoPath = data.getStringExtra(CameraManager.EXTRA_VIDEO_FILE_PATH);
.....          

if (requestCode == TAKE_IMAGE_REQUEST && resultCode == RESULT_OK) 
        {
            mimagePath = data.getStringExtra(CameraManager.EXTRA_PICTURE_FILE_PATH);
....                

where TAKE_VIDEO_REQUEST and TAKE_IMAGE_REQUEST are the same value you pass in the new Intent() .

An example here:

https://developers.google.com/glass/develop/gdk/camera#capturing_images_or_video

fpanizza
  • 1,589
  • 1
  • 8
  • 15
  • 1
    Just a side note, you could also use a `switch(requestCode)` instead of multiple if statements – TMH Jun 09 '14 at 14:19
  • Thank you very much! Let's say I want to upload that picture, how can I do that? I see that the picture is saved as a string. How can I upload the picture/video file to a php server. – Roi Bueno Jun 10 '14 at 07:24
  • You can find several samples... ie: http://stackoverflow.com/questions/17894549/uploading-image-onto-server , http://stackoverflow.com/questions/12789703/android-uploading-image-on-server-with-php – fpanizza Jun 10 '14 at 15:24