Reputation: 110
I am building an app that requires a front camera to work, I can check in runtime the list of available cameras with CameraManager.getCameraCharacteristics(cameraId)
and compare with CameraCharacteristics.LENS_FACING_FRONT
But is there a way in the camera2 api or using the android manifest to filter the application so that it can only be installed on devices that have a front camera?
This is what I have declared in AndroidManifest
<uses-feature
android:name="android.hardware.camera2"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
Upvotes: 1
Views: 759
Reputation: 12725
I think you need to add this feature:
<uses-feature
android:name="android.hardware.camera.front"
android:required="true" />
But this ALSO assumes that your app uses a android.hardware.camera
. And that's usually not a problem and devices with front camera usually have the back camera. But if you do not want that then add:
<uses-feature android:name="android.hardware.camera" android:required="false"/>
Upvotes: 1
Reputation: 1006964
Add <uses-feature android:name="android.hardware.camera.front" android:required="true"/>
to your manifest.
See the <uses-feature>
documentation for more about how to restrict your app to devices that have a front-facing camera, etc.
Upvotes: 0