Call handling

2

I was making an application that makes calls with the following code

Intent intent = new Intent(Intent.ACTION_CALL); 
intent.setData(Uri.parse(“tel:numerodetelefono”));    
activity.startActivity(intent);

There is some way to know how long the call lasted, not the time since you started calling but not the time the other person attended. And some method to cut the call made?

    
asked by Alejandro Ricotti 18.01.2017 в 21:37
source

1 answer

5

To measure the time of calls (incoming and outgoing) you can use code from Gabe Sechan, who published an abstract class PhoneCallReceiver . You find it in your answer here . Do not forget to give your vote if your code helps you.

In your Activity or Service you make a @Override :

private BroadcastReceiver br = null;

@Override
public void onCreate() {
    super.onCreate();
    br = new PhonecallReceiver() {
        @Override
        protected void onIncomingCallStarted(String number, Date start) {

        }

        @Override
        protected void onIncomingCallPickup(String number, Date start) {

        }

        @Override
        protected void onOutgoingCallStarted(String number, Date start) {
            // llamada saliente - guarda numero y fecha en un registro a tu gusto
        }

        @Override
        protected void onIncomingCallEnded(String number, Date start, Date end) {

        }

        @Override
        protected void onOutgoingCallEnded(String number, Date start, Date end) {
             // llamada saliente terminado. Busca el numero en tu registro y calcula la diferencia de las fechas
        }

        @Override
        protected void onMissedCall(String number, Date start) {

        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
    filter.addAction("android.intent.action.PHONE_STATE");
    registerReceiver(br,filter);
        //        Toast.makeText(getApplicationContext(),"Ring "+incomingNumber, Toast.LENGTH_LONG).show();
}

I will not share artifacts that allow the cutting of calls without user intervention for the same reason that I do not pass firearms to minors, nor do I leave them unattended in public. The code could easily be changed to make calls without user intervention. For security reasons and to avoid abuse (for example in the form of malware) Google does not support hacks of this type.

    
answered by 03.02.2017 в 05:26