简体   繁体   English

如何使用纹理视图编写用于相机预览的onPause()和onResume()方法

[英]How to write onPause() and onResume() method for Camera preview using Texture View

I copied an android custom camera making code. 我复制了一个android自定义相机制作代码。 I used camera api 1 and TextireView for layout. 我使用相机API 1和TextireView进行布局。

I'm stuck in onPause() and onResume() method, any suggestion to handle this methods . 我被困在onPause()onResume()方法中,任何处理此方法的建议。 Other methods like onSurfaceTextureUpdated() are ok. onSurfaceTextureUpdated()这样的其他方法也可以。 But because of pause and resume the original phone camera app stops, saying camera not available. 但是由于暂停和恢复,原来的手机摄像头应用程序停止了,原因是摄像头不可用。 I don't want to use surfaceView and surfac holder for camera implementation. 我不想在相机实现中使用surfaceView和surfac固定器。

You just need to make sure in your Activity that is using the Camera that in the onPause() method you release the camera. 您只需要确保在使用Camera的Activity中,在onPause()方法中释放相机即可。 In the onResume method is where you should start the Camera. 在onResume方法中,应该启动相机。 These two events should be completely independent of your method of displaying the preview really. 这两个事件应完全独立于您实际显示预览的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM