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

标签 android permissions warnings android-6.0-marshmallow android-permissions

我的代码

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/

相关文章:

android - RemoteViews 中的 ListView

java - Android:无法从用户存储读取文件

php - 无法写入目录 Laravel

linux - 如何正确使用组访问和chgrp?

ios - 警告 : UIAlertController is already presenting

php - array_filter() 期望参数 1 是 PHP 中的数组

android 模拟器 2.3.3 - 无法通过 adb 启动联系人应用程序

java - 如何在列表中添加某些路径?

java - Windows启动时如何启动Java Jar?

ios - 跟踪内存警告源 - iOS