I am trying to implement sip telephony, I found an example in the documentation and decided to do it
But in the end, I get
android.net.sip.SipException: Failed to create SipSession; network unavailable? Below is the source code.
public class MainActivity extends AppCompatActivity { public SipManager mSipManager = null; public SipProfile mSipProfile = null; String name,domain,sipAddress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); name = "name"; domain = "domain.ru"; sipAddress = "adress@adress.ru"; setContentView(R.layout.activity_main); SipProfile.Builder builder = null; if(mSipManager == null) { mSipManager = SipManager.newInstance(this); } try { builder = new SipProfile.Builder(name, domain); builder.setPassword("VEiVHXAyBDvtGbUD"); mSipProfile = builder.build(); } catch (java.text.ParseException e) { e.printStackTrace(); } try { Intent intent = new Intent(); intent.setAction("android.SipDemo.INCOMING_CALL"); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA); mSipManager.open(mSipProfile, pendingIntent, null); mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() { @Override public void onRegistering(String localProfileUri) { Log.d("SIP:", "onRegistering"); } @Override public void onRegistrationDone(String localProfileUri, long expiryTime) { Log.d("SIP:", "onRegistrationDone"); } @Override public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { Log.d("SIP:", "onRegistrationFailed"); } }); SipAudioCall.Listener listener = new SipAudioCall.Listener(){ @Override public void onCallEstablished(SipAudioCall call) { call.startAudio(); call.setSpeakerMode(true); call.toggleMute(); } @Override public void onCallEnded(SipAudioCall call) { Log.d("SIP:", "onCallEnded"); } }; mSipManager.makeAudioCall(mSipProfile.getUriString(), sipAddress, listener,30); Log.d("SIP:", "MakeAudioCall"); } catch (SipException e) { e.printStackTrace(); Log.d("SIP:", "SipException"); } } I get an exception after
mSipManager.makeAudioCall (mSipProfile.getUriString (), sipAddress, listener, 30);