-5

I am trying to make a simple Java client that uses tls to connect to and log into a ejabberd server. I use Android Studio or Eclipse.

I want a simple example that works.

Cœur
  • 37,241
  • 25
  • 195
  • 267
ZingMe
  • 1
  • 1
  • Welcome to Stackoverflow! To get the most out of the site it is important to ask good questions. A guide to asking questions is at: http://stackoverflow.com/help/how-to-ask – Stephen Rauch Jan 18 '17 at 07:10

1 Answers1

0

First you have to include the library to your project like this in gradle file:

Add SMACK API to android project by adding dependencies in build.gradle for the app.
 compile 'org.igniterealtime.smack:smack-android:4.1.4'
 // Optional for XMPPTCPConnection
 compile 'org.igniterealtime.smack:smack-tcp:4.1.4'
// Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats)
 compile 'org.igniterealtime.smack:smack-im:4.1.4'
// Optional for XMPP extensions support
 compile 'org.igniterealtime.smack:smack-extensions:4.1.4'

Then connect like this:

 XMPPTCPConnectionConfiguration.Builder configBuilder =      XMPPTCPConnectionConfiguration.builder();
   configBuilder.setUsernameAndPassword(userName, passWord);
   configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
  configBuilder.setResource("Android");
  configBuilder.setServiceName(DOMAIN);
 configBuilder.setHost(HOST);
 configBuilder.setPort(PORT);
  //configBuilder.setDebuggerEnabled(true);
  connection = new XMPPTCPConnection(configBuilder.build());
  connection.addConnectionListener(connectionListener);

Hope it will work.

prem nath
  • 75
  • 1
  • 12
  • Thanks. But, this will not work because it does not use tls because of configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); I have tried that exact example without success. – ZingMe Jan 18 '17 at 16:05