0

我有一个活动,该活动将方向设置为 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

该活动是从另一个也设置为横向的活动中调用的,如果我在将设备保持在横向状态时切换活动,它不会崩溃..仅在启动时将设备保持在纵向状态时..

在这两个活动中,我在 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));
4

1 回答 1

0

好的,看来如果我在清单中为该活动设置方向..问题就消失了..但我不明白为什么。
使固定:

android:screenOrientation="landscape"在活动清单中

于 2013-05-30T15:48:27.237 回答