zoukankan      html  css  js  c++  java
  • Android: requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

    在安卓上使用组件react-native-contacts报错,是需要添加联系人的时候,说是权限问题,配置了manifest文件后依然不起效果,

    解决方法:

      在需要引入react-native-contacts组件的页面,添加如下代码

     componentDidMount = () => {
            //Checking for the permission just after component loaded
            async function requestCameraPermission() {
                try {
                    const granted = await PermissionsAndroid.request(
                        PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS,{
                            'title': 'AndoridPermissionExample App Camera Permission',
                            'message': 'AndoridPermissionExample App needs access to your camera '
                        }
                    )
                    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
                        //To Check, If Permission is granted
                        alert("You can use the 通讯录");
                    } else {
                        alert("CAMERA permission denied");
                    }
                } catch (err) {
                    alert("err",err);
                    console.warn(err)
                }
            }
            if (Platform.OS === 'android') {
                //Calling the permission function
                requestCameraPermission();
            }else{
                alert('IOS device found');
            }
        }
    

      

  • 相关阅读:
    字符串转换成整数
    回文字符串判断
    字符串包含
    翻转单词顺序VS左旋转字符串
    穷举子集合
    求S=a+aa+aaa+aaaa+aa...a的值
    数组元素去重
    找最长等差数列的长度
    Git pull and push
    Google 开发console查找元素或方法
  • 原文地址:https://www.cnblogs.com/lude1994/p/11017610.html
Copyright © 2011-2022 走看看