1

我正在使用 cSipSimple 开发一个 Voip 应用程序。现在我想在第三方应用程序来电(whatsapp、instagram 等)时显示忙音通话自动继续保持,但下一个场景是,当第三方应用程序通话并且我正在接听时,我的 voip 通话仍在继续,第三方通话无法正常工作。 现在我想当第三方应用程序呼叫并且我接听电话时,我的 voip 呼叫处于保持状态,并且我正在与第三方呼叫连接。是否有任何方法或接收器来检测第三方来电?

我正在尝试这个当我的 Messenger 应用程序正在通话或想要拨打电话时,如何检测 Skype/telegram/whatsapp 呼叫?但它没有用。

我正在使用此代码检测 GSM 呼叫并将我的 voip 呼叫置于保持状态。

 public void onGSMStateChanged(int state, String incomingNumber) throws SameThreadException {
        // Avoid ringing if new GSM state is not idle
        if (state != TelephonyManager.CALL_STATE_IDLE && mediaManager != null) {
            mediaManager.stopRingAndUnfocus();
        }

        // If new call state is not idle
        if (state != TelephonyManager.CALL_STATE_IDLE && userAgentReceiver != null) {
            SipCallSession currentActiveCall = userAgentReceiver.getActiveCallOngoing();
            // If we have a sip call on our side
            if (currentActiveCall != null) {
                AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
                if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                    // GSM is now off hook => hold current sip call
                    hasBeenHoldByGSM = currentActiveCall.getCallId();
                    callHold(hasBeenHoldByGSM);
                    pjsua.set_no_snd_dev();
                    am.setMode(AudioManager.MODE_IN_CALL);
                } else {
                    // We have a ringing incoming call.
                    // Avoid ringing
                    hasBeenChangedRingerMode = am.getRingerMode();
                    am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                    // And try to notify with tone
                    if (mediaManager != null) {
                        mediaManager.playInCallTone(MediaManager.TONE_CALL_WAITING);
                    }
                }
            }
        } else {
            // GSM is now back to an IDLE state, resume previously stopped SIP
            // calls
            if (hasBeenHoldByGSM != null && isCreated()) {
                pjsua.set_snd_dev(0, 0);
                callReinvite(hasBeenHoldByGSM, true);
                hasBeenHoldByGSM = null;
            }

            // GSM is now back to an IDLE state, reset ringerMode if was
            // changed.
            if (hasBeenChangedRingerMode != null) {
                AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
                am.setRingerMode(hasBeenChangedRingerMode);
                hasBeenChangedRingerMode = null;
            }
        }
    }

提前致谢,我们将不胜感激!!

4

0 回答 0