0

I got a problem similar to (How to take multiple photos before dismissing camera intent?)!

how ever he used the:

Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);

I need to use somewhat like this:

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    for(int i=0;i<2;i++){
        fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

    // start the image capture Intent
        startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
   }

since i need to take exactly 2 photos, preview it with the default check or x of using MediaStore.ACTION_IMAGE_CAPTURE(to remove the hassle of displaying it to an imageview, go back again to capture)

then only go back to the main activity, knowing the data that i had taken 2 photos/saved it.

however, when i used that for loop, it returned only the last image taken, and it resized 2 times( i have a code that resizes 25% of the original captured photo, so after the code executed, it resized to 6.25% of original(1/4 of 25%) before it returns to the main activity).

Can someone give me light what is happening and give me a solution? Thanks a lot in advance! :D

As much as possible, i want to use the built in camera app, since it has a lot of other functions readily available compared to having the hassle of building your own custom camera. Btw im using android jellybean. 4.1.1

Community
  • 1
  • 1
user3115201
  • 111
  • 2
  • 14

1 Answers1

3

Call your second startActivityForResult() from the onActivityResult() you get from your first startActivityForResult(). Bear in mind that startActivityForResult() is asynchronous -- the other activity is not started right away.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • and then where would i handle the result of the 2nd? my app is a simple one, theres a mainactivity where there is a button named "capture image" and it has a button listener that calls the first startActivityForResult(). – user3115201 Feb 16 '14 at 11:23
  • @user3115201: "and then where would i handle the result of the 2nd?" -- also in `startActivityForResult()`. The code you pass to `startActivityForResult()` is supplied to `onActivityResult()`, to help you distinguish one call from the next. – CommonsWare Feb 16 '14 at 12:38
  • 1
    would it then produce an infinite loop of calling another startActivityForResult() once it handles the receiving data in onActivityResult() since it calls another startActivityForResult()? or maybe i can prevent it by declaring a global variable let's say int i, that would increment after the first call, then when it is already equal to 2, stop calling the next call? :D thank you so much man. – user3115201 Feb 16 '14 at 16:10
  • @user3115201: Use an `if` statement to examine the request code passed into `onActivityResult()` and decide how to handle that result. – CommonsWare Feb 16 '14 at 16:12
  • i already handled it man. thanks a lot. i noticed that there is just a lag happening since it returns to that same activity then calling another one. however its fine for me :) – user3115201 Feb 17 '14 at 08:07