发布Android相机而无需重启? [英] Release Android Camera without restart?

查看:272
本文介绍了发布Android相机而无需重启?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在试图让摄像头在我的应用程序工作,我在与整个 camera.release()的事情的问题;我做pretty的复杂的东西,有没有明确的方法来简单地调用 camera.release()所以我要不断尝试新的方式,但每次我弄错了我的应用程序崩溃(如预期),留下没有公布摄像头。因此,为了能够再次测试我的应用程序,我需要重新启动我的电话,以刷新相机。

I'm currently trying to get the camera working in my app and I'm having issues with the whole camera.release() thing; I'm doing pretty complicated stuff and there's no clear cut way to simply call camera.release() so I have to keep trying new ways, but every time I get it wrong my app crashes (as expected), leaving the camera not released. So, in order to be able to test my app again, I need to restart my phone in order to refresh the camera.

有没有办法通过终端或DDMS释放摄像头,或者是通过重新启动我的电话来释放它的唯一途径?这是越来越pretty的时候,特别是当一个微小的失误导致浪费时间等待我的手机重新启动。

Is there any way to release the camera through the terminal or DDMS, or is the only way to release it by restarting my phone? It's getting pretty old, especially when a tiny mistake leads to wasted time waiting for my phone to restart.

谢谢!

推荐答案

摄像头资源的管理是由Android摄像头服务(libcameraservice.so)完成。 运行相机服务的过程是媒体服务器。如果重新启动媒体服务器,你会有效地释放所有相机锁。

Camera resource management is done by the android Camera Service (libcameraservice.so). The process that runs Camera Service is mediaserver. If you restart the Media Server, you'll effectively release all camera locks.

您必须拥有亚洲开发银行root访问权限做到这一点。

You must have adb root access to do that.

运行亚行壳;苏来获得root的命令提示符。

Run adb shell; su to get root command prompt.

root@m0:/ # ps|grep media
media     1901  1     129268 6168  ffffffff 4026d470 S /system/bin/mediaserver
media_rw  1909  1     3064   1380  ffffffff 4015f1ac S /system/bin/sdcard
u0_a19    22821 1899  484316 21588 ffffffff 4016d574 S android.process.media
root@m0:/ # kill 1901
kill 1901

媒体服务器会自动现在开始。

Media server should be started automatically now.

这篇关于发布Android相机而无需重启?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆