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.
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!
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.
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 .
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.
Currently As specified by you there are 2 intents for capturing image and video i.e. MediaStore.ACTION_IMAGE_CAPTURE
& MediaStore.ACTION_VIDEO_CAPTURE
link.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With