2

这是我的注册码:

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 应用程序。

4

1 回答 1

0

我有什么似乎是类似的问题。当使用与基于官方 Android SIP 教程的示例非常相似的代码时,我看到两个失败的注册同时发生,其中一个给出了错误 -9。有时我也会收到错误 -10,DATA_CONNECTION_LOST。

在创建 Intent 后,我​​可以通过短暂睡眠来解决这两个问题:

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

于 2015-12-06T05:38:37.903 回答