Android原生SIP库注册失败(IN_PROGRESS)

时间:2013-10-08 06:57:39

标签: android sip

这是我的注册码:

SipProfile.Builder builder = new SipProfile.Builder(username, ip);
builder.setPort(Integer.parseInt(port));
builder.setPassword(password);
builder.setSendKeepAlive(true);
builder.setAutoRegistration(true);
sipProfile = builder.build();

Intent i = new Intent();
i.setAction(ACTION);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i,
        Intent.FILL_IN_DATA);
sipManager.open(sipProfile, pi, null);
sipManager.setRegistrationListener(sipProfile.getUriString(),
        new SipRegistrationListener() {
            public void onRegistering(String localProfileUri) {
                Log.e("SipService",
                        "Registering with SIP Server...\n"
                                + localProfileUri);
            }

            public void onRegistrationDone(String localProfileUri,
                    long expiryTime) {
                Log.e("SipService", "Ready: " + localProfileUri);
            }

            public void onRegistrationFailed(
                    String localProfileUri, int errorCode,
                    String errorMessage) {
                Log.e("SipService", "Error: " + errorCode + " " + rorMessage);
                Handler handler = new Handler(Looper
                        .getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {

                    Toast.makeText(SipService.this,
                        R.string.sip_registration_error,
                                Toast.LENGTH_LONG).show();
                    }
                });
            }
        });

虽然有时它注册成功,但大多数时候我收到错误代码-9:
10-08 14:49:53.389: E/SipService(5793): Error: -9 0
我在参考网站上找到了这个描述:

public static final int IN_PROGRESS
    The client is in a transaction and cannot initiate a new one.
    Constant Value: -9 (0xfffffff7)

这究竟意味着什么?我的手机上没有运行任何其他SIP应用程序。

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题。当使用类似于基于官方Android SIP教程的示例的代码时,我看到两次失败的注册同时发生,其中一个给出错误-9。有时我也得到错误-10,DATA_CONNECTION_LOST。

我能够通过在创建意图后短暂睡眠来解决这两个问题:

Intent intent = new Intent();
intent.setAction("my.package.name.INCOMING_CALL");
SystemClock.sleep(1000);
PendingIntent pendingIntent = PendingIntent.getBroadcast(parent, 0, intent, Intent.FILL_IN_DATA);
sipManager.open(mySipProfile, pendingIntent, null);
sipManager.setRegistrationListener(mySipProfile.getUriString(), new SipRegistrationListener() { ... }

建议:SIP:ERROR DATA_CONNECTION_LOST