【问题标题】:Linphone core listener not receiving incoming callsLinphone 核心监听器未接听来电
【发布时间】:2018-04-25 13:45:27
【问题描述】:

我正在尝试使用 linphone sdk 添加 sip 来电,注册成功,我可以拨打电话,并且通话状态按预期记录,但我无法接听来电。我正在使用意图服务来处理连接。

这是我的代码:

protected void onHandleIntent(Intent intent) {
        String sipAddress = intent.getStringExtra("address");
        String password = intent.getStringExtra("password");
        final LinphoneCoreFactory lcFactory = LinphoneCoreFactory.instance();

        // First instantiate the core Linphone object given only a listener.
        // The listener will react to events in Linphone core.
        try {
            lc = lcFactory.createLinphoneCore(new LinphoneCoreListenerBase() {
                @Override
                public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
                    super.callState(lc, call, state, message);
                    Log.i(TAG, "callState: ");
                }
            }, getApplication());
        } catch (LinphoneCoreException e) {
            e.printStackTrace();
        }
        lc.setUserAgent("Test app", "1.0");

        try {
            LinphoneAddress address = lcFactory.createLinphoneAddress(sipAddress);
            String username = address.getUserName();
            String domain = address.getDomain();
            if (password != null) {
                lc.addAuthInfo(lcFactory.createAuthInfo(username, password, null, domain));
            }
            // create proxy config
            LinphoneProxyConfig proxyCfg = lc.createProxyConfig(sipAddress, domain, null, true);
            proxyCfg.setExpires(2000);
            lc.addProxyConfig(proxyCfg); // add it to linphone
            lc.setDefaultProxyConfig(proxyCfg);


            running = true;
            while (running) {
                lc.iterate(); // first iterate initiates registration
                sleep(20);
            }
        } catch (LinphoneCoreException e) {
            e.printStackTrace();
        }
    }

我的代码有什么问题?

【问题讨论】:

  • (专业提示:我们更喜欢这里的技术写作风格。我们不鼓励问候,希望你能帮助,谢谢,提前感谢,感谢信,问候,亲切的问候,签名, please-can-you-helps, 聊天材料和缩写 txtspk, 恳求, 你被困了多久, 投票建议, 元评论等。只需解释你的问题, 并展示你尝试过的, 你期望的,以及实际发生的事情。)

标签: android voip sip-server


【解决方案1】:

正如 IntentService 文档 (https://developer.android.com/reference/android/app/IntentService) 所述:

服务根据需要启动,使用工作线程依次处理每个 Intent,并在工作结束时自行停止。

我认为您不应该将侦听器放在 IntentService 中。相反,将它放在一个长时间运行的 Service 中,以便侦听器实际上可以一直呆在那里接收事件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-18
    • 2022-09-28
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多