Venkat
Venkat

Reputation: 3457

how to block a out going call?

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 ?

Upvotes: 4

Views: 3322

Answers (1)

vipin
vipin

Reputation: 3001

<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

Upvotes: 3

Related Questions