androidvideocameraphotosgoogle-photos

start camera for both take picture OR record video


I googled for 2 weeks to find what I want. However, I am not able to find answer to my question and I have no idea how it could be done by Google Photos developers. The screenshots below are from Google Photos app.

When I click Take a photo, it starts(or opens) the camera and allows to take pictures OR record videos. I can also start camera to take picture and record video in different intents using following codes:

startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), ACTION_TAKE_PICTURE_RESULT_CODE);
startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE), ACTION_TAKE_VIDEO_RESULT_CODE);

Those lines works without any bug/problem. But my question is, how to start camera to take pictures OR record videos?

I hope my problem(question) is clear.

first second


Solution

  • This Intent open both the image and video

    Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    

    so use startActivityForResult

    startActivityForResult(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA), ACTION_TAKE_VIDEO_RESULT_CODE);