JDOaktown
JDOaktown

Reputation: 4467

android process camera image AFTERwards in OnActivityResult()

Per the Google Android camera tutorial I'm using:

new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

or

new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

to open the camera in my app.

Unfortunately, this forces the user to decide beforehand and prevents the user from toggling between pic & vid modes.

My problem is I want the user to go directly to the camera, be able to toggle between picture & video mode, and then save the image/video accordingly.

Is there some way to:

1) read the Intent data in onActivityResult() and

2) ascertain (AFTER the image has been saved, NOT before) whether it's a pic or a video,

then

3) rename the image to ".jpg" or ".mp4" accordingly?

I've noticed that when I use

new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);

that the camera can then toggle between pic & vid.

But then it won't programmatically save the file.

Upvotes: 1

Views: 143

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

I want the user to go directly to the camera, be able to toggle between picture & video mode, and then save the image/video accordingly.

That is not going to be possible in general, for the simple reason that you are asking other apps to take pictures and videos on your behalf. The protocol that Android has established for doing that is via the Intent actions that you are presently using. There is no ACTION_CAPTURE_SOMETHING_THAT_THE_USER_THINKS_IS_COOL or the equivalent that allows you to express that you want the user to make a choice after starting the third-party camera activity.

I've noticed that when I use new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA); that the camera can then toggle between pic & vid.

Only for the couple of camera apps that you have tried, out of thousands (pre-installed by device manufacturers, downloaded by users from the Play Store, etc.). The documentation certainly would not imply that behavior would be expected of all camera apps.

Upvotes: 2

Related Questions