powered by Jive Software

How can I register users using my app?

Hello, I want to know what I’m doing wrong, im trying to connect my android app to openfire to create new users from my app, but when i run the my app it doesnt throws any error, but it dont create new users, i will post my code, please tellme what i’m doing wrong, or i need a special configuration of my openfire server?

public class CrearUsuarioNumero extends Activity {

private EditText usuario, pass;

public static final String HOST = “192.ip.ip.ip”;

public static final int PORT = 5222;

public static final String SERVICE = “test”; <— name of my server

XMPPConnection connection;

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.numero);

usuario = (EditText) findViewById (R.id.editText1);

pass = (EditText) findViewById (R.id.editText2);

}

public void crear_onClic(View v){

create();

}

public void create(){

try{

ConnectionConfiguration connConfig =

new ConnectionConfiguration(HOST,PORT, SERVICE);

connection = new XMPPConnection(connConfig);

try{

connection.connect();

}

catch(XMPPException e){

Toast.makeText(this, "connexion eror: "+e,3000).show();

}

try{

AccountManager am = new AccountManager(connection);

Map<String, String> mp = new HashMap<String, String>();

String USERNAME= usuario.getText().toString();

String PASSWORD = pass.getText().toString();

mp.put(“usuario”, USERNAME);

mp.put(“contraseña”, PASSWORD);

am.createAccount(USERNAME, PASSWORD, mp);

}

catch(XMPPException e){

Log.d(“request!”, "starting7 "+e);

Toast.makeText(this, "Adding account Error: "+e,3000).show();

}

connection.disconnect();

}

catch (Exception e) {

}

}

}

my log is the picture

The log show nothing about xmpp packets, try to enable smack debugging and set the log level in android studio to Verbose or debug and add e.printStackTrace(); to your catch block maybe it’s not an xmpp exception.

catch (Exception e) {

e.printStackTrace();

}