Reputation: 886
I'm currently writing a application that needs to capture some images. I start the camera application using a intent like this:
if (v.equals(btnCap)) {
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
The problem is: When i tilt my device, the buttons on the camera still change their orientation and the picture I receive is not in portrait.
Does anyone know how to capture a image in portrait mode, even if the device is tilted?
Thanks in advance, Adrian
Upvotes: 3
Views: 920
Reputation: 13327
use setDisplayOrientation (int degrees) it will make the job
if you are using you own camera you can use it like this
camera.setDisplayOrientation(90);
http://code.google.com/p/android/issues/detail?id=1193#c42
Upvotes: 1
Reputation: 21564
You best option is to create your own camera app (http://developer.android.com/guide/topics/media/camera.html#custom-camera).
And then, in your AndroidManifest.xml, add the android:screenOrientation="portrait"
option on the declaration of your activity.
It's better to build your own camera activity, because you can have issues for getting the pictures depending on the device model. I once had an issue with Samsung devices (see Android Samsung: Camera app won't return intent.getData())
Upvotes: 1