4

I am blocking the incoming call by using following code,

{
     telephonyService = (ITelephony) method.invoke(telephonyManager);
     telephonyService.silenceRinger();
     telephonyService.endCall();
} 

But I want to know how to block the out going call ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Venkat
  • 3,447
  • 6
  • 42
  • 61

1 Answers1

3
<receiver android:name="MyPhoneReceiver">
            <intent-filter android:priority="100">
                <action android:name="android.intent.action.PHONE_STATE"></action>
                <action android:name="android.intent.action.NEW_OUTGOING_CALL"></action>
            </intent-filter>
        </receiver>

and in your broadcastreciever

@Override
    public void onReceive(Context context, Intent intent) {
      TelephonyManager telephony = (TelephonyManager)  context.getSystemService(Context.TELEPHONY_SERVICE);
CustomPhoneStateListener customPhoneListener = new CustomPhoneStateListener (context);
telephony.listen(customPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
}

with this you can get number

see this to block call How to Block outgoing calls and Text SMS check dharmendar answer

Community
  • 1
  • 1
vipin
  • 2,851
  • 4
  • 18
  • 32