Skip to content

TakePicture preferredCamera #126

Description

@CameronGoosen

I have 2 devices I'm testing on, when i set the PreferredCamera.Front for the TakePicture() this is what happens:
Mobicel MX3 = Opens selfie camera (CORRECT)
Samsung S21 = Opens rear camera (INCORRECT)

Same code, same build, any reason for this?

Activity

  1. yasirkula commented on May 20, 2025

    @yasirkula
    Owner

    I can confirm that PreferredCamera.Front isn't respected on S23 either. Sadly, this is the downside of using ACTION_IMAGE_CAPTURE Intent. It simply launches the default camera app on the device and Android OS hasn't implemented a way to enforce the front camera with this Intent. I'm using the following code which works on some/most camera apps but apparently not all:

    else
    {
    intent.putExtra( "android.intent.extras.LENS_FACING_FRONT", 1 );
    intent.putExtra( "android.intent.extras.CAMERA_FACING", 1 );
    intent.putExtra( "android.intent.extra.USE_FRONT_CAMERA", true );
    intent.putExtra( "com.google.assistant.extra.USE_FRONT_CAMERA", true );
    intent.putExtra( "camerafacing", "front" );
    intent.putExtra( "default_camera", "1" );
    }

    The only reliable solution is using Camera2/CameraX native APIs and creating our own native camera interface but I am not planning to do that for the time being. Instead I'll update the documentation to mention this problem.

  2. added a commit that references this issue on Jun 9, 2025
    3ec5b56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions