2012-06-02 61 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文件拍摄。

相关问题