I've made an simple flash application which toggles the flashlight. Everything works fine, but I'm having a few issues with the permission on API higher than 23.
In API 23 a new method was added for handling the flashlight mode. More precisely CameraManager.setTorchMode(String cameraId, boolean enabled)
.
This new method does not require to open the camera anymore just for handling the flashlight actions.
My problem is that below API 23, this method does not exist thus I need to access the camera, this forcing me to use the camera permission: <uses-permission android:name="android.permission.CAMERA"/>
in Manifest.
But I want to avoid requesting the camera permission on API higher than 23 as this won't affect the functionality of the application.
Does anyone know how I can request the camera permission only on APIs below 23?
Ionut Negru :
I found the solution for this. It seems the uses-permission allows for some customization and I found android:maxSdkVersion property to do just what I want.\n\n<uses-permission android:name=\"android.permission.CAMERA\" android:maxSdkVersion=\"23\"/>\n\nI hope this helps others in a similar situation.\n\nMore on this can be found in the official documentation: uses-permission",
2017-01-10T07:52:05