How to abort an outgoing call after fixed seconds?

2019-08-26 20:03发布

I am working on android app which can make missed call on other phone of particular duration like 5, 10 seconds, I am struck once call is made through a program to a particular number my program loose control, how I can end after some fixed no. of seconds after call is made, the general purpose SDK only allow to initiate call not for abortion.

I am new to android and done a deep search on net about this some folks refer using JAVA reflection and internal telephony for this but I wasn't able to do it, although I have done this on Symbian s-60 platform.

Any Suggestion?

2条回答
爷的心禁止访问
2楼-- · 2019-08-26 20:22

use telephony.aidl interface it consist method named endCall() which is used to terminate on going call

start timer in onReceive() method of broad cast receiver when your call is in Ringing state or in off-hook state

use endCall() method in that timer

Let me know if you need more things from me

查看更多
可以哭但决不认输i
3楼-- · 2019-08-26 20:26
    import android.content.BroadcastReceiver;
     import android.content.Context;
     import android.content.Intent;
     import android.util.Log;
     import android.widget.Toast;

     public class OutgoingCallReceiver extends BroadcastReceiver {


         @Override
         public void onReceive(Context context, Intent intent) {
    if(intent.getAction().equals(Intent.NEW_OUTGOING_CALL))
     {
       abortBroadcast ();
       }
    }
      }

Requires

<uses-permission android:name="android.permission.CALL_PHONE"/>
查看更多
登录 后发表回答