3

i have a android application where i tae a picture in a intend like this:

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(takePictureIntent, actionCode);

then i fill a ImageView with the result.

now i found a bug, then i want to take a picture and during the camera is open i rotate the screen and take the picture, i dont get a result in my ImageView.

Only when not rotating the camera, while taking a picture i see it in the ImageView.

how to solve this?

gurehbgui
  • 14,236
  • 32
  • 106
  • 178
  • Can you give a little bit more of your code? How I do it is use the pictureIntent in startActivityForResults and then retrieve the image like in the Google example: http://developer.android.com/training/camera/photobasics.html – Joris Oct 13 '12 at 17:16
  • I assume you have a get results method. Make sure your file location hasnt been cleaned because of rotate(aka you are looking in the wrong place). If it has, save it to a bundle, and reinitialse location onResume from the savedInstance. – IAmGroot Oct 13 '12 at 17:28
  • @Doomsknight - Post this as a answer, this is the solution :) – gurehbgui Oct 13 '12 at 17:32
  • @gurehbgui Ah cool. :) Done. I had this problem too, hence why it came to mind. – IAmGroot Oct 13 '12 at 17:34

1 Answers1

0

I assume you have a get results method.

Make sure your file location hasnt been cleaned because of rotate(aka you are looking in the wrong place).

I had this problem. I was setting a global variable of where to save the photo to. I passed this to the intent to take photo, and on return looked at that location to display photo.

However, if you rotate the screen, the global variable is destroyed, and so on result, it no longer knows where to find the photo.

The best thing to do is to save it to the saved instance, and reinitialse location onResume from the savedInstance.

See here on how to do it.

Community
  • 1
  • 1
IAmGroot
  • 13,760
  • 18
  • 84
  • 154