Android Wind
Android Wind

Reputation: 21

How to block incoming calls from unknown numbers programmatically?

I want to create an app that blocks all numbers that are not in contacts. I have read this but it is not perfect. How to do this? Thanks for reading

Upvotes: 2

Views: 2511

Answers (1)

Jame
Jame

Reputation: 3854

This is one way to use it. First, you have to use ITelephony in your project. I will give you an example to use it in below link. Second, you have to insert code to start service when you restart phone as follows:

in AndroidManifest File :

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Change this to :

@Override
public void onReceive(Context context, Intent intent) {
    Intent serviceIntent = new Intent(context,BackgroundService.class);
    startService(serviceIntent);
    }

The sample code at https://github.com/Levon-Petrosyan/Call_redirect_and_reject

Upvotes: 1

Related Questions