Question

I'm starting the camera via:

Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, PICTURE_RESULT);

It works without any errors. The only problem is when im returning, the layout is in Landscape mode eventhough im holding in portrait. Im able to get the image data here.

The screen returns to portrait-mode automatically after a short while, but then the data is lost.

Setting orientation in manifest does no effect.

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.camera"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.camera.MainActivity"
        android:configChanges="orientation"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Do you have any tips on how to return from camera to mainactivity in portrait?

Était-ce utile?

La solution

<activity
android:name="path.youractivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="landscape"/>

I have confusion about your Activity orientation so if you want to go with portrait then set the screenOrientation as portrait and for landscape set landscape

Try this way to setting the fixed orientation

I have updated I think it just because of screen size changed during orientation of activities. This was more affected from 4.0 I think so, Add this screensize in orientation and then test it

Autres conseils

try making your camera open in portrait mode with this

camera.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top