当我请求允许在本机中使用相机时,我的手机(Android 8.1.0)一直崩溃。我在Android Manifest中使用
android:targetSdkVersion="25"
。
componentDidMount(){
(async () => {
await this.requestCameraPermission();
})();}
async requestCameraPermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
'title': 'Cool Photo App Camera Permission',
'message': 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the camera")
} else {
console.log("Camera permission denied")
}
} catch (err) {
console.warn(err)
}
}