Je suis en train de se connecter à mon serveur Openfire en cours d'exécution avec ce code:Se connecter au serveur Openfire via Android
public static final String HOST = "ipofmyserver";
public static final int PORT = 9122; // set by me
//public static final String SERVICE = "gmail.com"; not used because i don't know what it refers to
ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT);
XMPPConnection connection = new XMPPConnection(connConfig);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Connect to the server
try {
connection.connect();
} catch (XMPPException e) {
connection = null;
//Unable to connect to server
}
//Most servers require you to login before performing other tasks.
if (connection != null) {
try {
connection.login("xxxx", "xxxx");
} catch (XMPPException e) {
e.printStackTrace();
}
}
}
LogCat
EDIT
j'ai ajouté une exception exceptionininitializer et maintenant il ne plante pas, mais maintenant je reçois:
05-07 03:27:55.734 3184-3184/xxx.xxx.xxxxxE/dalvikvm﹕ Could not find class 'javax.naming.directory.InitialDirContext', referenced from method org.jivesoftware.smack.util.dns.JavaxResolver.<clinit>
MISE À JOUR
j'ai lu que Android ne permet l'accès à certaines des classes standard, qui sont JRE dans cette liste blanche https://developers.google.com/appengine/docs/java/jrewhitelist
so .. Que dois-je faire si je veux utiliser l'api Smack? Je ne peux pas? J'ai essayé avec aSmack, mais il doit être compilé sur linux ou mac, et j'ai seulement obtenu des fenêtres
double possible (http://stackoverflow.com/questions/23507724/how -à-implémenter-xmpp-chat-dans-une-android-app) – Flow