You can use java reflection .
This is how I accessed the methods of the com.android.internal.telephony.ITelephony class to block an incoming call ...
private void endCall() throws Exception { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Class<?> c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); ITelephony telephonyService = (ITelephony) m.invoke(tm); telephonyService.silenceRinger(); telephonyService.endCall(); Toast.makeText(context, "Call Ended !", Toast.LENGTH_SHORT).show(); }
source share