To create XMPP connection in android you required smack.jar file in your project.
Download smack.jar file from Here
Add jar file in lib folder of your project and than add to build path.
To create connection with XMPP server first of all create XMPPConnection.
Use below code snippet for connection with server.
To create XMPP connection in your android put this below code in your activity for XMPP connection
That's it...
Hope this post may helpful for you...
Download smack.jar file from Here
Add jar file in lib folder of your project and than add to build path.
To create connection with XMPP server first of all create XMPPConnection.
Use below code snippet for connection with server.
ConnectionConfiguration config = new ConnectionConfiguration(“YOUR SERVER IP, PORT); XMPPConnection connection = new XMPPConnection(config);
To create XMPP connection in your android put this below code in your activity for XMPP connection
public class MainActivity extends Activity { XMPPConnection connection ; ConnectionConfiguration config; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new ConnectToXmpp().execute(); } private class ConnectToXmpp extends AsyncTask{ @Override protected Void doInBackground(Void... params) { config = new ConnectionConfiguration(“YOUR SERVER IP”, PORT); connection = new XMPPConnection(config); try { connection.connect(); connection.login("ADMIN USERNAME”, “ADMIN PASSWORD”); } catch (XMPPException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { } } }
That's it...
Hope this post may helpful for you...
No comments:
Post a Comment