gpt4 book ai didi

android - 如何在 Android Studio 中删除 "call requires permission which may.."错误

转载 作者:太空狗 更新时间:2023-10-29 16:31:04 25 4
gpt4 key购买 nike

我的代码

private void continueCall() {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + phoneNoToCall));
startActivity(callIntent);
}

上面要求用户是否在运行时授予权限CALL_PHONE,我已将其检查为

private void call() {
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
continueCall();
} else {
requestCallPermission();
}
}

Android studio 仍然显示错误“调用需要许可,这可能...”

如何消除这个错误?或者至少抑制它。

最佳答案

continueCall() 方法可以从多个地方调用。所以不能保证在 call()

中进行权限检查

所以你只能通过添加来抑制错误:

@SuppressWarnings("MissingPermission")

关于android - 如何在 Android Studio 中删除 "call requires permission which may.."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38719707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com