TomBomb
TomBomb

Reputation: 3296

Android - dynamically request camera access

I want to add the following permissions to my Android app, but doing so would block about 500 devices supported in my current build:

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

Is there any way to conditionally request access to the camera for some OS's and not others? Is the only way to achieve this to release two apps?

Upvotes: 2

Views: 1566

Answers (2)

Amitsharma
Amitsharma

Reputation: 1578

   Storage permition also insert over here in manifest file 

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

Upvotes: 0

ssantos
ssantos

Reputation: 16526

If your app uses the camera but it's not a mandatory feature, you can set required attribute to false, as you did with your second feature.-

<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" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

Upvotes: 2

Related Questions