简体   繁体   English

Android SIP注册失败(-9 IN_PROGRESS)

[英]Android SIP registration failed (-9 IN_PROGRESS)

Here is my registration code: 这是我的注册码:

    protected void initializeManagerOpen(){
    consoleWrite("initializeOpen");
    if(mSipManager==null) {
        return;
    }
    SipProfile.Builder builder;
    try {
        builder = new SipProfile.Builder("13", "10.0.0.4");
        builder.setPassword("13");
        builder.setPort(5062);
        builder.setProtocol("UDP");
        mSipProfile = builder.build();

        try {
            Intent intent = new Intent();
            intent.setAction("android.SipDemo.INCOMING_CALL");
            PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, Intent.FILL_IN_DATA);
            mSipManager.open(mSipProfile, pendingIntent, null);

            mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() {

                public void onRegistering(String localProfileUri) {
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_connecting,"Test","Connecting");

                    consoleWrite("Registering with SIP Server...");
                }

                public void onRegistrationDone(String localProfileUri, long expiryTime){
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_connected,"Test","Connected");

                    consoleWrite("Ready");
                }

                public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage){
                    mNotificationTask.endNotification();
                    mNotificationTask.createNotification(R.drawable.ic_stat_disconnected,"Test","Failed to connect:"+errorCode);

                    consoleWrite("Registration failed.  Please check settings.");
                    consoleWrite(""+errorCode);
                    consoleWrite(errorMessage);
                }

            });
        } catch (SipException e) {
            e.printStackTrace();
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

Though sometimes it registered successfully, most time I got a error code -9: 虽然有时它注册成功,但大多数时候我收到错误代码-9:

Registration failed.  Please check settings.
-9
0

I found this description on reference site: 我在参考网站上找到了这个描述:

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

What does it means exactly? 这究竟意味着什么? I don't have any other SIP application running on my phone. 我的手机上没有运行任何其他SIP应用程序。

PS. PS。 First time when i am trying to connect, it is working. 我第一次尝试连接时,它正在工作。 But second time it returns -9. 但第二次它返回-9。 Maybe i not close connection correctly? 也许我没有正确关闭连接? I think i have problem because i am trying to close connection but it is not closing... 我想我有问题,因为我试图关闭连接,但它没有关闭...

public void closeLocalProfile() {
    if(mSipManager==null){
        return;
    }
    try{
        if(mSipProfile!=null){
            mSipManager.close(mSipProfile.getUriString());

            consoleWrite("mSipManager Closed - "+mSipProfile.getUriString());
        }
    }catch(Exception e){
        consoleWrite("Failed to close local profile. - "+e);
    }
}

Delete all SIP account from Call Parameter and retry : 从“呼叫参数”中删除所有SIP帐户,然后重试:

Call App->Parameter->Call account internet Delete all account 呼叫App->参数 - >呼叫帐户互联网删除所有帐户

PS: Sorry for the name menu, my phone isn't in english PS:对不起名字菜单,我的手机不是英文的

I've faced the same issue and zicos22's comment helped me to solve it. 我遇到了同样的问题,zicos22的评论帮助我解决了这个问题。 The problem starts because of unclosed SipProfiles, so you need to run closeLocalProfile() inside onPause() method (it does not work when called inside onDestroy()). 问题的出现是因为未关闭的SipProfiles,所以你需要在onPause()方法中运行closeLocalProfile()(在onDestroy()内部调用它时不起作用)。 Actually, i think i have to run this sip stuff in separate thread, but for now i'm just closing profile in onPause. 实际上,我认为我必须在单独的线程中运行这个sip的东西,但是现在我只是关闭onPause中的profile。 On my android phone with ZenUI i'am able to close currently opened sip profiles manually in Settings -> Call Settings -> Phone Account Settings -> SIP accounts . 在我的带有ZenUI的Android手机上,我能够在设置 - >通话设置 - >电话帐户设置 - > SIP帐户中手动关闭当前打开的SIP配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM