0

Following problem: I am calling an activity "B" with extras. If B gets launched and has extras a ACTION_IMAGE_CAPTURE intent is on its way. This works really nice.

However, I have done this in onCreate() and therefore, everytime i change the orientation of my device, (and launched the activity before with extras) the camera gets on.

I tried to do clear();as well as remove() but this doesn't do the job for me.

Any suggestions? Thanks in advance

Aeefire
  • 888
  • 10
  • 25

1 Answers1

0

You can use onSaveInstanceState to maybe save a boolean to decide whether or not to keep the camera open. This method provides a bundle where you could insert that data, which you can access again during onCreate or onRestoreInstanceState. This is the preferred method of keeping an app working as expected during orientation changes.

For example, you might check if a photo was actually taken with the camera, then based on that information, insert a boolean value into the savedInstanceState Bundle through the onSaveInstanceState callback. When onCreate is called, check the provided Bundle for your boolean and choose whether or not to open the camera using that boolean.

Junseok Lee
  • 705
  • 5
  • 18