with statrtActivity(callIntent), call goes and then i have to wait for few seconds and end automatically. to end up my call i have taken mycalss extends Broadcastreceiver then in that onreceive() i implemented.in that method i got only to set old number and newnumber and toast is printing.
What i want exactly is to end call what i need to write. and how to call onreceive method from my class? plase help me. i didnt get anywhere.
 @Override
                public void onReceive(Context context, Intent intent) {                                 
                    final String oldNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);         
                    this.setResultData(newPhNnumber);                                                   
                    final String newNumber = this.getResultData();
                    if((newNumber!=null)&&(newNumber!=oldNumber))
                    {
                    String msg = "Intercepted outgoing call. Old number " + oldNumber + ", new number " + newNumber;
                    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
                    this.abortBroadcast();----> what it does?
                }
You may try this:
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try {
    Class c = Class.forName(tm.getClass().getName());
    Method m = c.getDeclaredMethod("getITelephony");
    m.setAccessible(true);
    ITelephony telephonyService = (ITelephony) m.invoke(tm);
    telephonyService.endCall();
} catch (Exception e) {
    e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With