简体   繁体   English

Android camera2 API

[英]Android camera2 api

I need to take a picture from camera where it goes to another activity where we have image view to show the picture taken through camera.My questions is how to pass image data through intents using camera2api? 我需要从相机拍摄照片,然后转到另一个活动,在该活动中我们有图像视图以显示通过相机拍摄的照片。我的问题是如何使用camera2api通过意图传递图像数据?

In which method in camera2api i need to pass data for another activity? 我需要在camera2api中的哪种方法中为其他活动传递数据?

You don't need Intent to pass image data from one Activity of your app to another. 您不需要Intent将图像数据从应用程序的一个活动传递到另一个活动。 Actually, you cannot use Intent to pass a picture: there are restrictions on the size of the data bundled with Intent. 实际上,您不能使用Intent传递图片:Intent捆绑的数据大小受到限制。 So, you can use Intent extras to pass the path to an image, or some parameters extracted from the image. 因此,您可以使用Intent Extras将路径传递到图像或从图像中提取的某些参数。 The Camera app uses intent extra("data") to return a thumbnail (very small) image. 相机应用使用意图extra("data")返回缩略图(非常小)图像。

Using the standard MediaStore.ACTION_IMAGE_CAPTURE Intent for latest devices which feature hardware.camera2 API is not different from the older devices that used the deprecated hardware.Camera . 对于具有hardware.camera2 API的最新设备,使用标准MediaStore.ACTION_IMAGE_CAPTURE目的与使用已弃用hardware.Camera的旧设备没有什么不同。

You can employ some private Intent-based mechanism to communicate between activities of your app. 您可以采用一些基于Intent的私有机制在应用程序的活动之间进行通信。 In this case the consumer will probably pass necessary parameters to capture activity with startActivityForResult() and get the results in onActivityResult() . 在这种情况下,使用者可能会传递必要的参数以使用startActivityForResult()捕获活动并在onActivityResult()获得结果。 There are no methods in hardware.camera2 that can (or could be expected to) help you with these tasks. hardware.camera2中没有可以(或可以预期)帮助您完成这些任务的方法。

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

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