Reputation: 3457
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
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