Android SIP registration failed (

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:

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.

PS. First time when i am trying to connect, it is working. But second time it returns -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 :

Call App->Parameter->Call account internet Delete all account

PS: Sorry for the name menu, my phone isn't in english


I've faced the same issue and zicos22's comment helped me to solve it. The problem starts because of unclosed SipProfiles, so you need to run closeLocalProfile() inside onPause() method (it does not work when called inside onDestroy()). Actually, i think i have to run this sip stuff in separate thread, but for now i'm just closing profile in onPause. 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 .

链接地址: http://www.djcxy.com/p/17912.html

上一篇: 来源:'的外部页面?

下一篇: Android SIP注册失败(