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.