Possible Duplicate:
Detect if an outgoing call has been answered
How can I know the moment when the person I call "picks up" his phone?
Possible Duplicate:
Detect if an outgoing call has been answered
How can I know the moment when the person I call "picks up" his phone?
As far as Android's telephony manager is concerned you cannot detect programmatically whether your call has been answered or not.
But for incoming calls it is possible, using PhoneStateListener
. When YOU 'pick up' the phone, the state changes to CALL_STATE_OFFHOOK
.
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
private PhoneStateListener mPhoneListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// do something...
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// you picked up the phone
break;
case TelephonyManager.CALL_STATE_IDLE:
// do something...
break;
default:
Log.d(TAG, "Unknown phone state=" + state);
}
} catch (RemoteException e) {}
}
};