Camera2 API - Android

試著忘記壹切 提交于 2019-12-20 01:55:18

问题


I am trying to use new camera api provided by android as camera2. But

CameraManager manager = (CameraManager) getActivity().getSystemService(Context.CAMERA_SERVICE);

showing error. Does any one have worked on this api.

Have been searching for results for could not find any thing yet.


回答1:


Binod,

That will only works if your platform support API level 21 - that is the one come after Android L release.

For a detailed explanation of how camera 2 API works, you may want to take a look at this article




回答2:


you can view this example may this will help you

Android Camera2Basic Sample

This sample demonstrates the basic use of Camera2 API. Check the source code to see how you can display camera preview and take pictures. Pre-requisites

Android SDK v21
Android Build Tools v21.1.1
Android Support Repository

https://github.com/googlesamples/android-Camera2Basic

Please check this Github Repo for Android L (API 21) Camera Preview Library PkmX/lcamera




回答3:


You need to make 2 classes for API 21 and lower, in lower use common Camera object, and in API 21+ you can use Camera2 API



来源:https://stackoverflow.com/questions/26925384/camera2-api-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!