I'm working on Android application that capture images and upload this images to a server. I used intent to open the camera:
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
I need to open the camera in landscape orientation, I tried this approach and nothing changed
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
Any advice please.
CodePudding user response:
The behavior of the camera app is up to the developers of the camera app. There are hundreds of camera apps, both pre-installed and user-installed. EXTRA_SCREEN_ORIENTATION
is not documented as being part of the ACTION_IMAGE_CAPTURE
protocol, and I am not aware of any camera apps that would honor it. There is no requirement for any camera app to let callers force a screen orientation.
You could integrate a camera library (CameraX from Google, etc.) and take photos yourself directly in your app. Then, you would be able to control the orientation of your screen (e.g., via android:screenOrientation
in the manifest).