Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. public SipManager mSipManager = null;
  2. public SipProfile mSipProfile = null;
  3. String username="100";
  4. String domain="192.168.56.1";
  5. String password="100";
  6.  
  7. @Override
  8. protected void onCreate(Bundle savedInstanceState) {
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.activity_main);
  11. lbl= (TextView) findViewById(R.id.label);
  12.  
  13.  
  14. if(mSipManager == null) {
  15. mSipManager = SipManager.newInstance(this);
  16. }
  17.  
  18. try {
  19.  
  20. SipProfile.Builder builder = new SipProfile.Builder(username,domain);
  21. builder.setPassword(password);
  22. mSipProfile = builder.build();
  23.  
  24. Intent intent = new Intent();
  25. intent.setAction("android.SipDemo.INCOMING_CALL");
  26. PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA);
  27. mSipManager.open(mSipProfile, pendingIntent, null);
  28.  
  29. mSipManager.setRegistrationListener(mSipProfile.getUriString(), new SipRegistrationListener() {
  30.  
  31. public void onRegistering(String localProfileUri) {
  32. lbl.setText("Registering with SIP Server...");
  33. }
  34.  
  35. public void onRegistrationDone(String localProfileUri, long expiryTime) {
  36. lbl.setText("Ready");
  37. }
  38.  
  39. public void onRegistrationFailed(String localProfileUri, int errorCode,
  40. String errorMessage) {
  41. lbl.setText("Registration failed. Please check settings.");
  42. }
  43. });
  44.  
  45.  
  46. //throw new SipException();
  47.  
  48. }catch (ParseException pe) {
  49. Log.i("STATE11","Connection Error.");
  50. }catch (SipException se ){
  51. Log.i("STATE11","Connection Error."+se);
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement