My code is:
const handleButtonPress = async () => { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.CAMERA, { title: 'Camera Permission', message: 'This app needs access to your camera to scan QR codes.', buttonPositive: 'OK', buttonNegative: 'Cancel', }, ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { setShowScanner(true); setScannedData(''); } else { console.log('Camera permission denied'); } } catch (err) { console.warn(err); }};
And I used a button to try to get permission to access to camera:
TouchableOpacity style={{ padding: 10 }} onPress={handleButtonPress}><Text style={{ fontSize: 20 }}>Scan QR Code</Text></TouchableOpacity>
I try to press the button to get the camera permission but it direct denied it without showing the pop-up.
I have added these lines in my AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" /><uses-feature android:name="android.hardware.camera" /><uses-feature android:name="android.hardware.camera.autofocus" />
I try to uninstall and reinstall also cannot get the pop-up.This caused me can't use the camera in my app.