2013-01-23 39 views
0

回報我通過啓動相機:Startactivity的結果,在橫向模式下

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

它的工作沒有任何錯誤。唯一的問題是,當我回來時,佈局是在風景模式eventhough im肖像舉行。我能夠在這裏獲取圖像數據。

屏幕短時間後自動返回肖像模式,但數據丟失。

在清單中設置方向不起作用。

清單:

<?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> 

你有關於如何從相機在人像返回mainactivity任何提示?

+0

您的活動試過嗎? android:screenOrientation =「portrait」 – R9J

+0

是的,我有!仍然返回風景,並在旋轉回肖像之後不久返回 – Sebastian

回答

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

我對你的Activity取向混亂,所以如果你想要去的portrait然後設置screenOrientation肖像landscape設置景觀

這種方式嘗試設置固定方向

我已更新我認爲這只是因爲在活動方向期間更改了屏幕大小。這是從4.0我也這麼認爲受到的影響更大,在定向添加此screensize並對其進行測試

+0

您的意思是screeOrientation =「portrait」? 我已經做了這個,它仍然在橫向返回 – Sebastian

+0

發佈您的androidmanifest.xml文件代碼 – Pratik

+0

我已經更新了這個問題! – Sebastian

0

嘗試使你的相機在人像模式下打開此

camera.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
+0

沒有效果。我認爲相機視圖鎖定在橫向上 – Sebastian