2011-12-07 32 views
0

我對ImageCapturing行爲感到困惑,但是當我從照相機保存照片(手機是肖像)時,我總是返回onCreate方法。當我捕捉和手機只在onResult和旋轉的onResume 90度(橫向),它工作正常,並進入ACTION_IMAGE_CAPTURE的奇怪行爲意圖 - 完成時進入onCreate

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
imageUri=Uri.fromFile(new File(imagesFolder,sfx));     
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri); 
cameraIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
startActivityForResult(cameraIntent,122); 

有人可以告訴我爲什麼?我把清單中的所有activityies android:screenOrientation="portrait"

+0

就以這個帖子一看:http://stackoverflow.com/questions/4901752/android-2-2-sdk-droid-x-camera-activity-doesnt-finish-properly/8679892#8679892我用一個醜陋的解決方法解決了關於額外調用onCreate函數的問題。 – Neonigma

回答

0

我建議加入下面的標誌在所有的活動:

android:configChanges="orientation|keyboard|keyboardHidden" 
0

發生這種情況,因爲如果Android的方向變化重新創建視圖。您需要將此添加到您調用相機意圖的活動的清單文件。

<activity 
    android:name=".YourActivity" 
    android:configChanges="orientation|keyboardHidden|screenSize" 
    android:screenOrientation="portrait" > 
</activity>