Android Add <uses-feature> in manifest
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> <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