2013-08-11 22 views
7

Android SipアプリケーションをAndroids Sipライブラリを使用してしばらくコーディングしていましたが、登録ができません。現在、SipManager.register()android.net.sip.SipException: SipService.createSession() returns nullと電話すると、私に次のエラーが表示されます。Android SipManager:android.net.sip.SipException:SipService.createSession()がnullを返す

私のコード:以下の出力が得られます

public static void Register(final String username, final String password, final String domain, final String cbf) 
     throws ParseException, SipException { 

    Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register"); 
    /* 
    * Luodaan SIP-profiili 
    */ 
    SipProfile.Builder builder = new SipProfile.Builder(username, domain); 
    builder.setPassword(password); 
    //builder.setProtocol("TCP"); 
    //builder.setPort(5060); 
    builder.setAutoRegistration(false); 
    _sipprofile = builder.build(); 

    Intent intent = new Intent(); 
    intent.setAction("android.jahtipuhelin.INCOMING_CALL"); 
    PendingIntent pendingIntent = PendingIntent.getBroadcast(_context, 0, intent, Intent.FILL_IN_DATA); 
    _sipmanager.open(_sipprofile, pendingIntent, new SipRegistrationListener() { 
     @Override 
     public void onRegistering(String s) { 
      Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 0"); 

     } 

     @Override 
     public void onRegistrationDone(String s, long l) { 
      Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 1"); 

      try { 
       _sipmanager.register(_sipprofile, 30, null); 
       _sipmanager.setRegistrationListener(_sipprofile.getUriString(), new JPSipRegistrationListener(_class, cbf)); 
      } catch (SipException e) { 
       Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage()); 
       e.printStackTrace(); 
      } 
     } 

     @Override 
     public void onRegistrationFailed(String s, int i, String s2) { 
      Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 2"); 
      Log.d(MainActivity.LOGTAG, s2); 

      try { 

       _sipmanager.register(_sipprofile, 30, null); 
       _sipmanager.setRegistrationListener(_sipprofile.getUriString(), new JPSipRegistrationListener(_class, cbf)); 
      } catch (SipException e) { 
       Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage()); 
       e.printStackTrace(); 
      } 
     } 
    });//*/ 

    Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - 2"); 
} 


private static class JPSipRegistrationListener implements SipRegistrationListener { 
    private MainActivity _parent; 
    private String _callBack; 

    public JPSipRegistrationListener(MainActivity ma, String callBack) { 
     this._parent = ma; 
     this._callBack = callBack; 
    } 

    @Override 
    public void onRegistering(String localProfileUri) { 
     Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistering"); 
     _parent.callSub(_callBack, REGISTERING, 0, ""); 
    } 

    @Override 
    public void onRegistrationDone(String localProfileUri, long expiryTime) { 
     Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationDone"); 

     _parent.callSub(_callBack, REGISTRATION_DONE, 0, ""); 
    } 

    @Override 
    public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { 
     Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationFailed"); 

     Log.e(MainActivity.LOGTAG, "Virhe Sip-rekisteröinnissä: "+errorCode+": "+errorMessage); 
     if (errorCode == -10) { 
      return; 
     } 
     _parent.callSub(_callBack, REGISTRATION_FAILED, errorCode, errorMessage); 
    } 

} 

が稼働して:

08-11 18:50:58.276 24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register 
08-11 18:50:58.436 24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - testi 2 
08-11 18:50:58.436 24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: registration not running 
08-11 18:50:58.446 24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - 2 
08-11 18:50:58.666 24449-24465/fi.hieta.aatu.android.jahtipuhelin E/fi.hieta.aatu.android.jahtipuhelin: class android.net.sip.SipException: SipService.createSession() returns null 

誰もが私がここで間違ってやっているか知っていますか?また、自動登録を使用せずに、sipプロファイルを手動で登録しようとしています。 (btw私の最初の質問stackoverflowので、穏やかにしてください:)

+0

モバイルデータ接続を使用して登録しようとしていますか? –

答えて

4

更新:そのソリューションでは例外が消えたが、私はすべての呼び出しを受け取ることができませんでした。

解決策が見つかりました。電話をかける前に電話をかける必要があります。 さらに、オープンしているリスナーを使用しないでください(SipDemoにはその理由がわかりません)。登録後に登録してください(私のために働きます)。

だから私のコードは次のとおりです。

manager.open(localProfile, pendingIntent, null); 

manager.register(localProfile, 20, listener); 

manager.setRegistrationListener(localProfile.getUriString(), listener); 
+1

setRegistrationListenerは必要なく、Android 4.4.4のNexus 4でも動作しましたが、Android 4.4.4を実行しているNexus 5でもSipService.createSession()はnullを返します。 – Toubey

5

同じエラーコードが生じ、少なくとも別の癖があるようです。あなたの携帯電話で同じリクエストURIを持つ事前定義されたアカウントを持っている場合は、あなたのアプリケーションで作成しようとしている2つ目はこの方法で失敗します。このアカウントは、着信コール(=バックエンドのSIP登録)に設定されていなくても発生します。 Androidチームがこのバグを修正したり、少なくとも意味のあるエラーを投げることを願っています。

関連する問題