Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to end up my outgoing call.

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?
                }
like image 664
Deepu Mandy Avatar asked Oct 23 '22 08:10

Deepu Mandy


1 Answers

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();
}
like image 83
PhatHV Avatar answered Nov 01 '22 11:11

PhatHV