can somebody explain me how to create an account and log into it(I'm talking about creating account in Openfire)? We need to log into someone's account and then create a new one but how to log into that new one? I don't have any idea how to do this. Please help me!!!
This is my code:
connection.login(Usrname, Password);
AccountManager accountManager = AccountManager.getInstance(connection);
//Log.e(tag, String.valueOf(accountManager.supportsAccountCreation()));
accountManager.createAccount(Usrname1, Password1);
//How to log into created account here?
P.s. tell me what's wrong with my question before setting -1
Thank you.
Edit My code
public void connectionInitialization(){
new connect().execute();
}
public class connect extends AsyncTask<Void,Void,Void>{
@Override
protected Void doInBackground(Void... voids) {
try {
XMPPTCPConnectionConfiguration.Builder connectionConfiguration = XMPPTCPConnectionConfiguration.builder();
//connectionConfiguration.setUsernameAndPassword(, "12345678");
connectionConfiguration.setHost("192.168.2.106");
connectionConfiguration.setServiceName("192.168.2.106");
connectionConfiguration.setConnectTimeout(12000);
connectionConfiguration.setSecurityMode(XMPPTCPConnectionConfiguration.SecurityMode.disabled);
connectionConfiguration.setPort(5222);
connectionConfiguration.setResource("test");
connectionConfiguration.setDebuggerEnabled(true);
connection = new XMPPTCPConnection(connectionConfiguration.build());
XMPPTCPConnectionListener xmpptcpConnectionListener = new XMPPTCPConnectionListener();
connection.addConnectionListener(xmpptcpConnectionListener);
Log.e(tag, "connecting started");
connection.connect();
AccountManager.getInstance(connection).sensitiveOperationOverInsecureConnection(true);
Map<String,String> attributes = new HashMap<String, String>(2);
attributes.put("name", "Donald Duck");
attributes.put("email", "foo@bar.fb");
AccountManager.getInstance(connection).createAccount("kagyn", "12345678", attributes);
AccountManager.getInstance(connection).sensitiveOperationOverInsecureConnection(false);
Log.e(tag, "Success");
}catch (XMPPException e){
Log.e(tag,"Connect_XMPPException " + e.getMessage());
}catch (SmackException | IOException e){
Log.e(tag, "Connect_SmackOrIOException " + e.getMessage());
}
return null;
}
}
public class XMPPTCPConnectionListener implements ConnectionListener{
@Override
public void connected(XMPPConnection connection1) {
Log.e(tag,"connected");
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
Log.e(tag,"authenticated");
}
@Override
public void connectionClosed() {
Log.e(tag,"connectionClosed");
}
@Override
public void connectionClosedOnError(Exception e) {
Log.e(tag,"connectionClosedOnError " + e.getMessage());
}
@Override
public void reconnectionSuccessful() {
Log.e(tag, "reconnectionSuccessful");
}
@Override
public void reconnectingIn(int seconds) {
Log.e(tag,"reconnectingIn");
}
@Override
public void reconnectionFailed(Exception e) {
Log.e(tag, "reconnectionFailed " + e.getMessage());
}
}