in case someone is looking for the answer, here's the code (you never know when that link is gonna die!). This is not the complete code, but it's the code that will listen to a call change. What I didn't get when reading the documentation the first time was that getting a CALL_STATE_IDLE response, means that the connection that was there before is now idle - i.e., the call has been disconnected.
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
private class ListenToPhoneState extends PhoneStateListener {
public void onCallStateChanged(int state, String incomingNumber) {
Log.i("telephony-example", "State changed: " + stateName(state));
}
String stateName(int state) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE: return "Idle";
case TelephonyManager.CALL_STATE_OFFHOOK: return "Off hook";
case TelephonyManager.CALL_STATE_RINGING: return "Ringing";
}
return Integer.toString(state);
}
}