I have set up a xmpp server and android client using the great post here... I have some pre defined users set up in the xmpp server and i could login with those credentials.
I want to update the answer to reflect the change in Asmack library version 4.0 onward. Connection.getAccountManager() is now AccountManager.getInstance(XMPPConnection)
AccountManager accountManager=AccountManager.getInstance(connection);
try {
accountManager.createAccount("username", "password");
} catch (XMPPException e1) {
Log.d(e1.getMessage(), e1);
}