作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我的代码
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/
我是一名优秀的程序员,十分优秀!