How to get the duration of call started from your app?
In my app, when开发者_开发问答 someone clicks on a button, a phone call is started. Can i detect when the phone call is finished, so i will be able to measure the duration of this call?
Tnx.
For call start, use a BroadcastReceiver
for the Intent with action android.intent.action.NEW_OUTGOING_CALL
. For the call end you want to use a BroadcastReceiver
for the Intent with action android.intent.action.PHONE_STATE
. The Intent you receive will have an extra, TelephonyManager.EXTRA_STATE
, with value TelephonyManager.EXTRA_STATE_IDLE
when the call ends. You can then setup your interval timer values and track the duration.
精彩评论