// Do nothing if the connection is null, or connection is not established, or
// connection is authenticated
if (connection == null || !connection.isConnected() || connection.isAuthenticated()) {
return;
}
String username = "alice"; // username without '@'
String password = "123456"; // this user's password
try {
connection.login(username, password);
} catch (XMPPException e) {
Log.e("login", "XMPPException: "+e.getMessage());
} catch (IllegalStateException e) {
Log.e("login", "IllegalStateException: "+e.getMessage());
} catch (Exception e) {
Log.e("login", "Exception: "+e.getMessage());
}
After connection established, we need to login to an account
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.