Shirish Herwade Shirish Herwade - 1 year ago 77
Android Question

how to remove "call requires permission which may.." error in Android Studio

My code

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

Above requires whether user grant permission
at run time which I have checked as

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

Still Android studio showing error "call requires permission which may..."

How to remove this error? Or at least suppress it.

Answer Source

The method continueCall() could be called from multiple places. So it isn't guaranteed to have the permission check in call()

So you can only suppress the error by adding: