我有一个活动可以为活动设置lanscape的方向,但是如果活动启动时手机处于纵向模式,我会收到此错误并且活动停止并返回到其他活动:
05-30 11:06:48.335: D/DOMX(125): ERROR: failed check:(eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore) - returning error: 0x80001005 - Error returned from OMX API in ducati
05-30 11:06:48.335: E/CameraHAL(125): Error while configuring rotation 0x80001005
05-30 11:06:48.460: D/DOMX(125): ERROR: failed check:(eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore) - returning error: 0x80001005 - Error returned from OMX API in ducati
05-30 11:06:48.460: E/CameraHAL(125): Error while configuring rotation 0x80001005
05-30 11:06:48.765: E/CameraHAL(125): Adapter state switch PREVIEW_ACTIVE Invalid Op! event = 0xf
正在从另一个也设置为横向的活动调用活动,如果我在横向保持设备的同时切换活动,则不会崩溃..只有在启动时将设备保持为纵向时才会出现.. < / p>
在两个活动中我都在onCreate()中设置方向,如下所示:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
这似乎与我正在启动的活动中放置一个CameraPreview表面的事实有关,所以我包含了相机类的问题:
public class KNCamLayer extends SurfaceView {
Camera camera;
SurfaceHolder previewHolder;
public KNCamLayer(Context context)
{
super(context);
previewHolder = this.getHolder();
//previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
previewHolder.addCallback(surfaceHolderListener);
}
SurfaceHolder.Callback surfaceHolderListener = new SurfaceHolder.Callback() {
public void surfaceCreated(SurfaceHolder holder) {
camera=Camera.open();
try {
camera.setPreviewDisplay(previewHolder);
}
catch (Throwable e){ }
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
Parameters params = camera.getParameters();
//params.setPreviewSize(width, height);
params.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(params);
camera.startPreview();
}
public void surfaceDestroyed(SurfaceHolder arg0)
{
camera.stopPreview();
camera.release();
}
};
public void onResume() {
camera.startPreview();
}
public void onPause() {
// TODO Auto-generated method stub
camera.stopPreview();
}
}
CameraView被添加到活动的onResume()中,如下所示:
camPreview = new KNCamLayer(this);
frame.addView(camPreview, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
答案 0 :(得分:0)
好的,似乎如果我在该活动的清单中设置方向......问题消失了......但我不明白为什么。
固定:
android:screenOrientation="landscape"