Android Add <uses-feature> in manifest

I am very confused where to add

used, function

in the manifest. I use the camera in my application. I added permission, but I'm confused where to add features to use the front camera. You can help?

+6
source share
5 answers
0
source

Add this under the <manifest> , for example:

  <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.lalllala"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-feature android:name="android.hardware.camera" /> <application android:icon="@drawable/icon" android:label="lalla" android:debuggable="true"> </application> </manifest> 
+10
source

<uses-feature> - Declares one hardware or software function used by the application.

The purpose of the announcement is to inform any external object about the set of hardware and software functions on which your application depends. The element offers the necessary attribute, which allows you to indicate whether your application is required and cannot function without the declared function, or it prefers to have this function, but can work without it. Since feature support may vary between Android devices, this element plays an important role in allowing the application to describe the functions of the device variable that it uses. read more

Below is a sample code to access Device Front Camera

 public Camera openFrontFacingCamera() { int cameraCount = 0; Camera ffCam = null; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); // Find the total number of cameras available cameraCount = Camera.getNumberOfCameras(); // Find the ID of the CAMERA_FACING_FRONT & open it for (int camIdx = 0; camIdx < cameraCount; camIdx++) { Camera.getCameraInfo(camIdx, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { try { ffCam = Camera.open(camIdx); } catch (RuntimeException e) { Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage()); } } } return ffCam; } 

The following permissions are required

 <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.front" android:required="false" /> 

Read the Google android developer API doc Camera , Camera.CameraInfo for details

+3
source

write tags how to do it

 <manifest> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <application> </application> </manifest> 
0
source

Add this under the manifest tag:

 <!-- Request the camera permission --> <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="true" /> 
0
source

Source: https://habr.com/ru/post/887176/


All Articles