Linphone核心侦听器未接听来电 [英] Linphone core listener not receiving incoming calls

查看:370
本文介绍了Linphone核心侦听器未接听来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was trying to add sip incoming calls with linphone sdk, The registration is successful and I can make out going calls and the call status is logging as expected, but I am not able to receive incoming calls. I am using intent service to handle connection.

这是我的代码:

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();
        }
    }

我的代码有什么问题?

推荐答案

作为IntentService文档(

As the IntentService document (https://developer.android.com/reference/android/app/IntentService) stated:

该服务将根据需要启动,使用工作线程依次处理每个Intent,并在工作耗尽时自行停止.

the service is started as needed, handles each Intent in turn using a worker thread, and stops itself when it runs out of work.

我认为您不应将侦听器放在IntentService中.而是将其放在运行时间较长的Service中,以便侦听器实际上可以一直停留在此处以接收事件.

I think you should not put the listener in an IntentService. Instead, put it in a long running Service so that the listener can actually keep staying there to receive events.

这篇关于Linphone核心侦听器未接听来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆