我正在使用 Camera Api,因为当我启动应用程序时,它会显示后置摄像头,它工作正常,但是当我单击前置摄像头按钮时,它会得到运行时异常 无法连接摄像头服务
in camera = Camera.open(cameraID);
in front camera button code :
if (cameraID == Camera.CameraInfo.CAMERA_FACING_BACK)
{
Toast.makeText(getApplicationContext(), "Front Camera", Toast.LENGTH_LONG).show();
cameraID = Camera.CameraInfo.CAMERA_FACING_FRONT;
}
else if (cameraID == Camera.CameraInfo.CAMERA_FACING_FRONT)
{
Toast.makeText(getApplicationContext(), "Back Camera", Toast.LENGTH_LONG).show();
cameraID = Camera.CameraInfo.CAMERA_FACING_BACK;
}
Intent intent = getIntent();
finish();
startActivity(intent);