未解析的引用Manifest.permission.CALL_PHONE

问题描述 投票:0回答:1

我有一个 Android 移动应用程序,我正在尝试在其中构建直接呼叫功能。我已在清单文件中添加了所需的权限请求。但在我尝试拨打电话的函数中,出现错误,显示未解析的引用:CALL_PHONE。

这是我的私人功能:

private fun callPhone(patientTelephone: String?) {
    if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.CALL_PHONE)
        != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this@MainActivity,
            arrayOf(Manifest.permission.CALL_PHONE),
            REQUESTCALL)
    }else {
        val intentCall = Intent(
            Intent.ACTION_CALL,
            Uri.fromParts(
                "tel",
                patientTelephone,
                null
            )
        )
        startActivity(intentCall)
    }
}

manifest文件中的权限请求是这样的:

使用权限 android:name="android.permission.CALL_PHONE"

目标SdkVersion 33

android-permissions
1个回答
1
投票

android.Manifest
导入到您的班级即可解决。

© www.soinside.com 2019 - 2024. All rights reserved.