Android Native SIP Stack not registering client(Android Native SIP堆栈未注册客户端)
问题描述
我正在使用Android SIP进行VOIP
调用。它正在向asterisk server
成功注册。现在,它有时不注册asterisk server
,也不触发任何SipRegistrationListener回调方法。
try {
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword("my_password");
builder.setProtocol("UDP");
builder.setSendKeepAlive(true);
builder.setAutoRegistration(true);
SipProfile sipProfile = builder.build();
SipManager manager = SipManager.newInstance(this);
Intent intent = new Intent();
intent.setAction("app.package.INCOMING_CALL");
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_ACTION);
manager.open(sipProfile, pi, null);
manager.setRegistrationListener(sipProfile.getUriString(), new SipRegistrationListener() {
@Override
public void onRegistering(String s) {
Log.i("SIP Registration", "onRegistering()");
}
@Override
public void onRegistrationDone(String s, long l) {
Log.i("SIP Registration", "onRegistrationDone()");
}
@Override
public void onRegistrationFailed(String s, int i, String s1) {
Log.wtf("SIP Registration", "onRegistrationFailed()");
}
});
} catch (ParseException e) {
e.printStackTrace();
} catch (SipException e) {
e.printStackTrace();
}
在我的代码中manager.open()
之后,没有调用任何注册侦听器。我们知道VOIP
还有其他第三方库可用。但这将需要大量的返工。
推荐答案
我也被困住了,看起来原生的sip堆栈非常有漏洞!
主要问题是:
-我们不能同时使用多个sip帐户。只有第一个帐户正在注册,并且所有后续帐户都会失败,直到您关闭第一个帐户(通常会抛出IN_PROGRESS错误)
-有时它甚至不创建帐户(此时它可能会抛出错误,甚至根本不调用监听器)。
我仍然无法找到修复程序,但要使其最终注册,您需要执行以下操作:
1)从您的应用程序关闭当前打开的sip配置文件
2)进入手机应用-设置-互联网账户的设置(路径可能不同)。你所有的sip账户都列在那里了。检查sip帐户列表是否为空
3)如果列表中有帐户,请手动关闭
4)重新启动设备
5)启动你的应用程序,尝试打开并注册sip配置文件。多田!现在注册正常。怪异
这篇关于Android Native SIP堆栈未注册客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!