在“旧”相机 API 时代,我使用了简单的代码:
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(imageIntent, CAPTURE_IMAGE);
效果很好。
现在使用camera2,示例代码大约有1035行代码 - android-camera2Basic example .
是否有更简单的方法来使用新的camera2-API 拍照?
最佳答案
In the days of the "old" camera-API I used the simple code:
该代码与“旧的相机 API”(android.hardware.Camera
) 无关。
Isn't there a simpler way of just taking a picture with the new camera2-API ?
你问题中的代码工作得很好......在 the limits of the camera apps that you might be linking to 内.
实现 android.hardware.Camera
比 android.hardware.camera2.*
容易一些,但也不是很多,而且这两个 API 都非常复杂。
关于java - 在android中使用camera2拍照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42910729/