Guest User

Untitled

a guest
Apr 26th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. protected void onHandleIntent(Intent intent) {
  2. String sipAddress = intent.getStringExtra("address");
  3. String password = intent.getStringExtra("password");
  4. final LinphoneCoreFactory lcFactory = LinphoneCoreFactory.instance();
  5.  
  6. // First instantiate the core Linphone object given only a listener.
  7. // The listener will react to events in Linphone core.
  8. try {
  9. lc = lcFactory.createLinphoneCore(new LinphoneCoreListenerBase() {
  10. @Override
  11. public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
  12. super.callState(lc, call, state, message);
  13. Log.i(TAG, "callState: ");
  14. }
  15. }, getApplication());
  16. } catch (LinphoneCoreException e) {
  17. e.printStackTrace();
  18. }
  19. lc.setUserAgent("Test app", "1.0");
  20.  
  21. try {
  22. LinphoneAddress address = lcFactory.createLinphoneAddress(sipAddress);
  23. String username = address.getUserName();
  24. String domain = address.getDomain();
  25. if (password != null) {
  26. lc.addAuthInfo(lcFactory.createAuthInfo(username, password, null, domain));
  27. }
  28. // create proxy config
  29. LinphoneProxyConfig proxyCfg = lc.createProxyConfig(sipAddress, domain, null, true);
  30. proxyCfg.setExpires(2000);
  31. lc.addProxyConfig(proxyCfg); // add it to linphone
  32. lc.setDefaultProxyConfig(proxyCfg);
  33.  
  34.  
  35. running = true;
  36. while (running) {
  37. lc.iterate(); // first iterate initiates registration
  38. sleep(20);
  39. }
  40. } catch (LinphoneCoreException e) {
  41. e.printStackTrace();
  42. }
  43. }
Add Comment
Please, Sign In to add comment