DEV Community

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

Collapse
 
surbhivsambare profile image
SurbhiVSambare

I want the calls should get blocked .. how I can achieve that..?

Collapse
 
nikola profile image
Nikola Brežnjak

What have you tried so far?

Collapse
 
surbhivsambare profile image
SurbhiVSambare

Thank you for your response.. I want to block the outgoing calls.. when my application is going in background.. I have written the following code with the help of stackoverflow but the code is not working:-

Will be waiting for your response.. thank you in advance.

public class OutgoingCallBlocking extends BroadcastReceiver {

String number;

@SuppressLint("WrongConstant")
@Override
public void onReceive(Context context, Intent intent) {
    number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    setResultData(null);
    Toast.makeText(context, "Outgoing Call Blocked "+ number , 5000).show();
}

}