0
嗨我想開發一個應用程序來呼叫和應答呼叫,下面的代碼我得到答案「SipManager已關閉」和吐司「未註冊」。SIP註冊 - Android Studio
我沒有得到任何異常,並且「setRegistrationListener」中的Toast從未啓動。
出了什麼問題?問題是什麼?
private void inicializarPerfilLocal(){
if(mSipManager == null){
Toast.makeText(getApplicationContext(), "Error al iniciar administrador SIP", Toast.LENGTH_LONG);
return;
}
String username = COUNTRYCODE+PHONE_NUMBER;
String domain = "xx.yy.zz";
String password = "ABCABCABC";
try{
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
builder.setAuthUserName(username+"@"+domain);
builder.setOutboundProxy("255.255.255.0");
builder.setProfileName(username + "@" + domain);
builder.setDisplayName("Test");
builder.setProtocol("TCP");
builder.setAutoRegistration(true);
mSipProfile = builder.build();
Intent i = new Intent();
i.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
mSipManager.open(mSipProfile, pi, null);
if (mSipManager.isOpened(mSipProfile.getUriString())){
Toast.makeText(getApplicationContext(), "Administrador abierto", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Administrador cerrado", Toast.LENGTH_LONG).show();
}
mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() {
public void onRegistering(String localProfileUri) {
Toast.makeText(getApplicationContext(), "Registrando...",
Toast.LENGTH_LONG).show();
}
public void onRegistrationDone(String localProfileUri, long expiryTime) {
Toast.makeText(getApplicationContext(), "Registrado",
Toast.LENGTH_LONG).show();
}
public void onRegistrationFailed(String localProfileUri, int errorCode,
String errorMessage) {
Toast.makeText(getApplicationContext(), "Error en registro errorCode :: "+errorMessage,
Toast.LENGTH_LONG).show();
}
});
if (mSipManager.isRegistered(mSipProfile.getUriString())){
Toast.makeText(getApplicationContext(), "Registrado", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No registrado", Toast.LENGTH_LONG).show();
}
}catch(ParseException pe){
Toast.makeText(getApplicationContext(), "Excepcion de parseo", Toast.LENGTH_LONG).show();
}catch(SipException se){
Toast.makeText(getApplicationContext(), "Excepcion SIP", Toast.LENGTH_LONG);
}
}
Hi Ravi!關於您的推薦,IP和端口是打開的,因爲我使用CSIPSimple配置服務並且它可以正常工作。關於第二個建議,我改爲「UDP」,現在我有「SipManager打開」但未註冊。在日誌中出現「-9」(RegistrationFailed -9 :: 0)和「-4」(RegistrationFailed -4 :: registration not running)錯誤。 –
請通過tcpdump檢查日誌以及您在tcpdump上獲得的錯誤類型。希望它必須是CSIPSimple接受各種標題,但你的應用程序不 – Ravi