问题
I am using Android SIP for VOIP calling. It was registering successfully with asterisk server. Now, sometimes it's not registering with asterisk server and not any SipRegistrationListener callback method firing.
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();
}
After manager.open() in my code, not any registration listener is called. We know there are other 3rd party libraries are available for VOIP. But there will be lot of rework for that.
回答1:
I'm stuck with that too, looks like native sip stack is extremely buggy!
Main issues are:
- we can't use several sip accounts at once. Only the first one is being registered and all following accounts fail until you close the first one (usually they throw IN_PROGRESS error)
- sometimes it even doesn't create an account (at this point it may throw an error or even not to call the listener at all).
I still can't find the fix, but to make it finally register you'd do this:
1) from your app close currently opened sip profile
2) go to the phone app - settings - internet accounts' settings (the path may differ). All your sip accounts are listed there. Check that the list of sip accounts is empty
3) if there are accounts in the list - close them manually
4) reboot your device
5) start your app and try to open and register the sip profile with it. TADA! Registers fine now. Weird
来源:https://stackoverflow.com/questions/49414650/android-native-sip-stack-not-registering-client