DEV Community

Discussion on: How to make a native Android app that can block phone calls

Collapse
 
ruthvik47 profile image
Ruthvik47

It won't work,it will ask MODIFY_PHONE_STATE permission to block the calls.Now android is not allowing MODIFY_PHONE_STATE permissions to third party applications.

Collapse
 
bajithelearner profile image
Baji Shaik

Exactly, did you find any solution for this?

Collapse
 
ruthvik47 profile image
Ruthvik47

Nope

Collapse
 
ishan001 profile image
Ishan Khandelwal

Use TelecomManger to end call programatically for Android 9 and above using ANSWER_PHONE_CALL permission.

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ANSWER_PHONE_CALLS) == PackageManager.PERMISSION_GRANTED) {
success = tm.endCall();
Log.d("call state", "call end");
}
}