锁定相机时,例如错误/解锁装置
我用相机工作,我使用的文件中给出的相同的例子:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Camera$p$pview.html
I'm working with the camera and I'm using the exact same example given in the documentation : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html
我在运行示例上的Xoom与Android 3.1和3.2。
I running the example on a Xoom with Android 3.1 and 3.2.
我的问题是,当我锁定和解锁的Xoom,相机不回来。图像保持不变的最后一个之前,我锁定了平板电脑和红灯不回来无论是。
My problem is when I lock and unlock the Xoom, the camera doesn't come back. The image stay the same as the last one before I locked the tablet and the red light doesn't come back either.
如果有人可以帮助我,我会AP preciate。
If anyone could help me, I will appreciate.
通过锁定和解锁,你的意思是,当屏幕睡觉或设备电源开关为pressed把装置进入休眠状态,然后唤醒备份?
By lock and unlock, do you mean when the screen sleeps or the device power switch is pressed putting the device to sleep and then woken back up?
如果是这样,我怀疑你需要释放相机资源在你的onPause,然后在onResume再次启动preVIEW,通过表面观回调。
If so, I suspect you need to release the camera resources in your onPause and then start the preview again in onResume, via the surface view callback.
在Android 2.2和2.3的应用程序我有一个处理相机我用的模式是:
In the Android 2.2 and 2.3 apps I have that deal with camera the pattern I use is:
onCreate:
- get reference to the camera
onResume:
- sv = (SurfaceView)this.findViewById(R.id.capture_SurfaceView);
mHolder = sv.getHolder();
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mHolder.setSizeFromLayout();
mHolder.addCallback(this);
surfaceChanged:
- Camera.setPreviewDisplayHolder()
- Camera.startPreview()
onPause:
- Camera.stopPreview
- SurfaceHolder.removeCallback()
- Camera.release()
这很适合我整个设备入门关闭,然后再打开,或我的应用程序,否则会背景。
This works well for me across the device getting turned off and then back on, or my app otherwise going to background.