• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Is there a clean way to get call dialing time?

joakoman

Lurker
I know I can get the dialing call state through android.internal.telephony.call package, but I don't really want to use the internal library for my project. Do you people know if theres another way to get OFF-HOOK intermediate states or dialing time? Thanks in advance.
 
I'm not sure whether I understand your question. But you can use a broadcast receiver to listen to the action "android.intent.action.PHONE_STATE"

//register incoming call receiver
IntentFilter phonestateFilter = new IntentFilter("android.intent.action.PHONE_STATE");
registerReceiver(phonestateReceiver, phonestateFilter);

then in your receiver you can check whether the phone state is the following:

TelephonyManager.EXTRA_STATE_RINGING
TelephonyManager.EXTRA_STATE_OFFHOOK
TelephonyManager.EXTRA_STATE_IDLE


public void onReceive(Context context, Intent intent){

if (intent.getAction().equals("android.intent.action.PHONE_STATE")){

phoneState = bundle.getString(EXTRA_STATE);

if(phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)){

// the user is offhook now..

//get time

Date time = new Date();

}


}


However, outgoing call has its own intent action, which is "android.intent.action.NEW_OUTGOING_CALL", which requires another receiver.

In other words, you first receive outgoing call intent, and then receive the phone_state intent, for which you want to capture the "TelephonyManager.EXTRA_STATE_OFFHOOK"
To differentiate the offhook caused by outgoing calls from by incoming calls, you need to check whether you have ever received "TelephonyManager.EXTRA_STATE_RINGING". If not, that's caused by outgoing call. If yes, that's an incoming call.

Hope this helps you.

}
 
Back
Top Bottom