Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch native camera app with option to capture either video or image

Tags:

android

camera

I've written an app before where I open the native camera app to capture an image like this:

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

Or, like this for capturing video:

Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

But is there a way to open the native camera app with the option to capture either video or an image? I'd like to open to the image given below, where the user can swipe to access the side-menu and change their input type.

Image Below

I've tried searching, but no results have come up yet. I'm not sure if there is a way to do this without writing a custom camera implementation, which I'd like to avoid for now.

If this is possible, how can I do it? And how could I go about recognizing what media type the user has chosen once the capture is complete (in onActivityResult, probably)?

Thank you in advance!

like image 592
pez Avatar asked Feb 23 '15 05:02

pez


People also ask

How can we launch an existing camera application in the Android app?

Modify src/MainActivity. java file to add intent code to launch the Camera. Add the Camera permission and run the application and choose a running android device and install the application on it and verify the results. Following is the content of the modified main activity file src/MainActivity.

Which intent action do you use to take a picture with a camera app?

The Android Camera application encodes the photo in the return Intent delivered to onActivityResult() as a small Bitmap in the extras, under the key "data" . The following code retrieves this image and displays it in an ImageView .

What is the permission for using the camera in Android Studio?

Camera Permission - Your application must request permission to use a device camera. Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission. For a list of camera features, see the manifest Features Reference.


1 Answers

Currently As specified by you there are 2 intents for capturing image and video i.e. MediaStore.ACTION_IMAGE_CAPTURE & MediaStore.ACTION_VIDEO_CAPTURElink.

For intially I was also thinking startActivityForResult (Intent intent, int requestCode, Bundle options), Here options param was used to give the extras for the external applications but we can only specify some animations not the values as specified link1 & link2.

Solution

I would rather suggest you to go for the custom app with options as you like rather than the restrictions given by the existing camera app.

like image 81
TechArcSri Avatar answered Oct 09 '22 00:10

TechArcSri