To intercept your call, you just need to:
1. Make a package with a name. com.android.internal.telephony;
2. In this package, create an interface file named ITelephony.
and write this code in this interface file.
boolean endCall(); void answerRingingCall(); void silenceRinger();
Now in your class where you want to intercept the call, extend this class to BroadcastReceiver and write the following code in the onReceive() function.
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try { Class c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); telephonyService = (ITelephony) m.invoke(tm); Bundle bundle = intent.getExtras(); String phoneNumber = bundle.getString("incoming_number"); Log.d("INCOMING", phoneNumber); if ((phoneNumber != null)) { telephonyService.endCall(); Log.d("HANG UP", phoneNumber); } } catch (Exception e) { e.printStackTrace(); }
Here it is.
Zubair Feb 22 '13 at 20:38 2013-02-22 20:38
source share