锁定/解锁设备时相机示例错误
我正在使用相机,并且使用文档中给出的完全相同的示例: http://developer.android .com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html
我在装有 Android 3.1 的 Xoom 上运行该示例, 3.2.
我的问题是当我锁定和解锁 Xoom 时,相机无法恢复。图像与锁定平板电脑之前的最后一张图像保持一致,并且红灯也没有出现。
如果有人可以帮助我,我将不胜感激。
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
I running the example on a Xoom with Android 3.1 and 3.2.
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.
If anyone could help me, I will appreciate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
锁定和解锁是指当屏幕休眠或按下设备电源开关使设备休眠然后唤醒时?
如果是这样,我怀疑您需要在 onPause 中释放相机资源,然后通过表面视图回调在 onResume 中再次启动预览。
在 Android 2.2 和 2.3 应用程序中,我有处理相机的模式,我使用的模式是:
这对我来说很有效,设备关闭然后重新打开,或者我的应用程序进入后台。
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?
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.
In the Android 2.2 and 2.3 apps I have that deal with camera the pattern I use is:
This works well for me across the device getting turned off and then back on, or my app otherwise going to background.
一种解决方案可能是在 onResume() 中将 SurfaceView 设置为不可见并再次可见,这会使 SurfaceView 销毁并重新创建。
One solution maybe setting the surfaceview to invisible and visible again in onResume(), this makes the surfaceview destroy and recreates.