/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
PermissionsAndroid,
Platform
} from 'react-native';
async function 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)
}
}
requestCameraPermission()
if(Platform.Version === 23){
console.log('Running on Lollipop!');
}
export default class myproject2 extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('myproject2', () => myproject2);
问题是这样的,我想获取某个权限,看过官网的API也查了一些资料我在AndroidManifest.xml里面是配置过的,手机和模拟器都是安卓6.0的,SDK的版本是23都是没有问题,但是我在测试的时候就发现,当我调用了,他是直接返回true的,显示的是You can use the camera,在浏览器的控制台里,但是APP里没有任何反应这是为什么呢?我非常的困扰。我非常的不解,我想问下,大家是这么写的,还是说还要配置其他的什么吗?