react-native - Expo ImagePicker在android中无法正常工作
问题描述
请求许可componentDidMount
async componentDidMount() {
await Permissions.askAsync(Permissions.CAMERA);
await Permissions.askAsync(Permissions.CAMERA_ROLL);
}
照片选择器功能
_takePhoto = async () => {
let pickerResult = await ImagePicker.launchCameraAsync({
allowsEditing: true,
aspect: [4, 3]
});
this._handleImagePicked(pickerResult);
};
渲染区域
<TouchableOpacity onPress={this._takePhoto}>
<Text> Upload Image </Text>
</TouchableOpacity>
版本
Expo SDK : "^31.0.2"
Tested android version: 7.1
应用程序中的权限
"READ_PHONE_STATE",
"CAMERA",
"READ_INTERNAL_STORAGE",
"WRITE_INTERNAL_STORAGE",
"READ_EXTERNAL_STORAGE",
"WRITE_EXTERNAL_STORAGE"
当我构建 apk 并在设备中运行它时,当我单击按钮时,我的相机没有打开。内部博览会工作正常。
解决方案
推荐阅读
- php - 切换到 mysqli 时 PHP 代码不再有效
- ecmascript-6 - 如何在 ES6 类的回调函数中访问“self”?
- selenium - 如何基于 Protractor 的相对值构建 xpath / css-selector
- ubuntu - 尝试在 Ubuntu 16.04 上使用 cmake 时出错
- python - 如何在 QTableWidget 中将布尔项显示为复选框?
- python - Dedupe Python - “记录不符合数据模型”
- node.js - 无法使用节点从数据存储中检索数据
- javascript - Three.js:从后期处理中添加 BloomEffect
- spring-integration - EnpointSpec 在 Spring Integration Java DSL 中失败
- scrapy - 如果刮板空闲超过 20 秒,则产生更多请求