Gaurav Pansheriya
Gaurav Pansheriya

Reputation: 175

Call Blocking in android with Use IT Telephoney Class

I use this code to block a incomming Calls in android Application..

AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); 

audioManager.setStreamMute(AudioManager.STREAM_RING, true);

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(telephonyManager.getClass().getName());

Method method = clazz.getDeclaredMethod("getITelephony");

method.setAccessible(true);

com.android.internal.telephony.ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);

telephonyService.silenceRinger();

telephonyService.endCall();

This Code is not work Properly.. At least one time ringging a phone and after cut calls.. Please.. Some one Give me better solution..

Upvotes: 1

Views: 225

Answers (1)

Gaurav Pansheriya
Gaurav Pansheriya

Reputation: 175

Thanks to u. Problem is that at least one time ringging device and after cut calls so not cut calls but missed calls..

Upvotes: 1

Related Questions