学习Camera碰到的问题

xiaoxiao2021-02-28  11

1.ISurfaceHolder.AddCallback(this):这里回调函数添加的内容是当前的Activity,当前Activity需实现ISurfaceHolderCallback接口,并实现接口方法

public void SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int width, int height) { //throw new NotImplementedException(); } public void SurfaceCreated(ISurfaceHolder holder) { //throw new NotImplementedException(); this.InintCamera(); } public void SurfaceDestroyed(ISurfaceHolder holder) { //throw new NotImplementedException(); if (this.camera != null) { if (this.isPreview) { this.camera.StopPreview(); this.camera.Release(); this.camera = null; } } }

2.Camera.Open(); 报错:java.lang.RuntimeException: Fail to connect to camera service

解决:未赋Camera权限:android.permission.CAMERA

转载请注明原文地址: https://www.6miu.com/read-250207.html

最新回复(0)