2012-06-02 197 views
0

我有一個相機應用程序,我希望每當相機打開時,它僅在橫向模式下拍攝圖像?我怎麼能做到這一點?強制相機在橫向模式下拍攝圖像

Intent ia = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(ia,cameraData); 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    // TODO Auto-generated method stub 
    Log.d("value of pic1", ""+pic1); 
    super.onActivityResult(requestCode, resultCode, data); 
    if(resultCode == RESULT_OK){ 
     Bundle extras = data.getExtras(); 
     Bitmap bmp1 = (Bitmap) extras.get("data"); 
    } 
} 
+0

看[這裏](http://stackoverflow.com/questions/8294868/issues-takeing-picture-with-android-vertical-camera-portrait) – Renard

回答

1

在AndroidManifest.xml文件中,您爲應用程序指定了可接受的方向。

要強制您的活動保持橫向模式,只需在活動的定義標記中添加android:screenOrientation標記即可。

<activity android:name=".SomeActivity" android:label="@string/app_name" android:screenOrientation="landscape"> 

如果你打開本機應用程序,那麼你不能迫使相機在橫向模式下拍攝圖像。您不會在您的應用程序中對您的本機應用程序進行定向控制。

+1

我打開相機應用程序..我認爲要實現這個,我必須改變我無法訪問的相機應用程序的清單? – Kumar

1

要做到這一點,你可以自己的相機預覽活動,而不是打開意圖。您可以通過遵循this示例輕鬆完成此操作。並將動作方向模式設爲風景。

1

使用該setDisplayOrientation U可以做這件事 see here

+0

我看到這需要API 14,我目前正在使用API​​ 8 ..是否有用? – Kumar

+0

@Kumar在這裏檢查這一個http://stackoverflow.com/questions/4645960/how-to-set-android-camera-orientation-properly –

0

指定定向landscap爲perticular活動標籤,在其屏幕是要求在AndroidManifest.xml文件拍攝。

相關問題