What permission I need in order to use camera flash in camera preview?

前端 未结 2 526
有刺的猬
有刺的猬 2020-12-14 03:07

I have a custom camera application and I need to be able to turn flash on(torch mode actually)/off.

What kind of permission do I need in this case?

1.Only

相关标签:
2条回答
  • 2020-12-14 03:27

    According to android developers permission-group:

    Note that this element does not declare a permission itself, only a category in which permissions can be placed. See the <permission> element for information on declaring permissions and assigning them to groups

    You would need two permissions Manifest.permission:

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    

    to be able to access the camera and the flashlight.

    And you would need to declares the hardware features that is used by the application (camera and flash) Features Reference:

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

    android:required indicates whether phones not having these hardware can install your application or not.

    On your third point, I think you have a type because uses-permission tag can not be used with android.hardware...

    <uses-permission android:name="android.hardware.camera.flash"/>
    
    0 讨论(0)
  • 2020-12-14 03:30

    Maclir answer is showing all the detail of permission required to use camera and its flash light. you can also use these two permission to use flashlight in your application.

        <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" />
    
    0 讨论(0)
提交回复
热议问题