Android: How to monitor the call state in more detail than provided by telephonymanager.getCallState()?

145 Views Asked by At

I have tried to monitor a call triggered by an Android application through telephonymanager.getCallState() or the respective listener like so:

Log.d(TAG, " callState - " + telephonyManager.getCallState());

OR

telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

class StateListener extends PhoneStateListener {
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            super.onCallStateChanged(state, incomingNumber);
            switch (state) {
                case TelephonyManager.CALL_STATE_RINGING:
                    Log.d(TAG, "CALL_STATE_RINGING " + incomingNumber + " state " + state);
                    break;
                case TelephonyManager.CALL_STATE_OFFHOOK:
                    Log.d(TAG, "CALL_STATE_OFFHOOK " + incomingNumber + " state " + state);
                    break;
                case TelephonyManager.CALL_STATE_IDLE:
                    Log.d(TAG, "CALL_STATE_IDLE " + incomingNumber + " state " + state);
                    break;
                default:
                    Log.d(TAG, "default" + incomingNumber + " state " + state);
                    break;
            }
        }
};

However, I can only receive the status CALL_STATE_OFFHOOK or CALL_STATE_IDLE.

Is there some other API that helps in receiving a more detailed view on outgoing phone calls? My goal is to have a list of numbers, e.g. 3 numbers, and call each number until someone picks up. However, if I cannot monitor if the receiver actually picked up the phone or was not reachable, I cannot see myself through this.

best regards

0

There are 0 best solutions below