7

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

Mirjalal
  • 1,292
  • 1
  • 17
  • 40

2 Answers2

4

But my question is, how to start camera to take pictures OR record videos?

You don't, if you want to get the result. There is no ACTION_IMAGE_OR_VIDEO_CAPTURE, for example. You would need to allow the user to choose what to do before starting ACTION_IMAGE_CAPTURE or ACTION_VIDEO_CAPTURE.

I have no idea how it could be done by Google Photos developers. The screenshots below are from Google Photos app.

Your question has nothing to do with Google Photos. After all:

  • Not every device has Google Photos installed
  • Not every device that has Google Photos installed has it enabled
  • Not every device that has Google Photos installed and enabled has it available to the user (e.g., restricted profiles)
  • The user might still choose some other app to handle your Intent, if the user has other camera apps installed
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

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);
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • let me try this – Mirjalal May 21 '17 at 09:32
  • 3
    yes, `INTENT_ACTION_STILL_IMAGE_CAMERA` gives me what I want. but after taking picture or recoding video action I am not able to get taken file (photo/video). It does not return result (value). – Mirjalal May 21 '17 at 09:58
  • that link helped to figure out that what happens when `INTENT_ACTION_STILL_IMAGE_CAMERA` used. http://stackoverflow.com/a/11638308/4057688 – Mirjalal May 21 '17 at 10:04
  • 2
    MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA This intent does not support activity results or specific intent file outputs. This intent is designed to simply open the camera. The functionality you seek does not exist natively in Android. – King of Masses Sep 20 '17 at 04:19