I want to show a notification when a call is active.
I have done the first easy part. Notification starts when my call intent starts.
Now to the tricky part, how can I tell my Notification that the call has ended?
views:
73answers:
1
+1
A:
You need to register a PhoneStateListener on the TelephonyManager.
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
PhoneStateListener listener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_IDLE) {
// hangup
}
}
};
tm.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
To unregister your PhoneStateListener:
tm.listen(phoneListener, PhoneStateListener.LISTEN_NONE);
Schildmeijer
2010-02-22 13:28:58
which state is the "hang up state" . Can only see STATE_RINGING, STATE_OFFHOOK, STATE_IDLE
f0rz
2010-02-22 13:46:09
You start listening for the STATE_IDLE after a call has been initiated that will indicate that the call has ended
Donal Rafferty
2010-02-22 14:23:40