How to detect answered or rejected state in outgoing call
Asked Answered
C

1

5

i try to write a program for android .I want to make a call with my program and after that recognize the call status. With Flowing Function I can recognize the hang out status and for answering status it doesn’t work.I try this function but it doesn’t work either

private class PhoneCallListener extends PhoneStateListener {

    private boolean isPhoneCalling = false;

    String LOG_TAG = "LOGGING 123";

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        if (TelephonyManager.CALL_STATE_RINGING == state) {
            // phone ringing
            Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
        }

        if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
            // active
            Log.i(LOG_TAG, "OFFHOOK");

            isPhoneCalling = true;
        }

        if (TelephonyManager.CALL_STATE_IDLE == state) {
            // run when class initial and phone call ended, need detect flag
            // from CALL_STATE_OFFHOOK
            Log.i(LOG_TAG, "IDLE");

            if (isPhoneCalling) {

                Log.i(LOG_TAG, "restart app");

                // restart app
                Intent i = getBaseContext().getPackageManager()
                        .getLaunchIntentForPackage(
                                getBaseContext().getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);

                isPhoneCalling = false;
            }

        }
    }
}
Contrived answered 14/2, 2013 at 16:34 Comment(1)
Welcome to SO. Please check out the FAQ and About pages for information on how best to ask questions. In this instance you need to be specific about "doesn't work" - error messages/what does/doesn't happen etc etc.Frisch
F
-2

You can not do that with CALL_STATE_IDLE and CALL_STATE_OFFHOOK. You have to detect programatically the end of outgoing ringtone...

Foucault answered 14/2, 2013 at 16:41 Comment(1)
Thanks a lot . how can i do this?Contrived

© 2022 - 2024 — McMap. All rights reserved.