使用自定义的wpml在msdk进行航线上传出现的问题

Completed

Comments

3 comments

  • Boerma

    你应用有读取外部存储的权限吗?

    0
    Comment actions Permalink
  • zhang

    应用有读取外部存储的权限,在manifest中添加了,我也检查了一下,是有权限的

    private fun checkPermission() {
    if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.READ_EXTERNAL_STORAGE)
    != PackageManager.PERMISSION_GRANTED) {
    // 权限未被授予,申请权限
    requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), REQUEST_CODE_READ_EXTERNAL_STORAGE)
    } else {
    // 权限已被授予,可以进行读取操作
    //readStorage()
    Toast.makeText(requireContext(), "读取存储权限被允许", Toast.LENGTH_SHORT).show()
    println("读取存储权限被允许")
    }
    }

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    when (requestCode) {
    REQUEST_CODE_READ_EXTERNAL_STORAGE -> {
    if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
    // 用户授予了读取存储的权限
    //readStorage()
    Toast.makeText(requireContext(), "读取存储权限被允许", Toast.LENGTH_SHORT).show()
    println("读取存储权限被允许")
    } else {
    // 用户拒绝了读取存储的权限
    Toast.makeText(requireContext(), "读取存储权限被拒绝", Toast.LENGTH_SHORT).show()
    println("读取存储权限被拒绝")
    }
    }
    REQUEST_CODE_LOCATION_PERMISSION -> {
    // 检查定位权限请求的结果
    if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
    // 用户授予了定位权限
    getLocation()
    } else {
    // 用户拒绝了定位权限
    Toast.makeText(requireContext(), "定位权限被拒绝", Toast.LENGTH_SHORT).show()
    }
    }
    }
    }
    0
    Comment actions Permalink

Please sign in to leave a comment.