Sono in grado di aggiungere il gruppo, ma mostra "La stanza è bloccata dall'immissione finché la configurazione non viene confermata". Ho fatto delle ricerche ma non ho trovato nessuna risposta soddisfacente. Di seguito è riportato il codice su come ottenere la connessione XMPP e l'invio del modulo. E durante l'invio del modulo lancia "Eccezione non autorizzata".IN XMPP ottenere l'eccezione non autorizzata (401), durante l'invio del modulo
xmppConnection = connectionThread.getXMPPConnection();
if (xmppConnection == null) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
return;
}
final MultiUserChat multiUserChat;
try {
multiUserChat = new MultiUserChat(xmppConnection, room);
// setConfig(multiUserChat);
} catch (IllegalStateException e) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
return;
}
// Codice per l'invio del modulo.
private void setConfig(MultiUserChat multiUserChat) {
try {
Form form = multiUserChat.getConfigurationForm();
Form submitForm = form.createAnswerForm();
for (Iterator<FormField> fields = submitForm.getFields(); fields
.hasNext();) {
FormField field = (FormField) fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType())
&& field.getVariable() != null) {
submitForm.setDefaultAnswer(field.getVariable());
}
}
submitForm.setAnswer("muc#roomconfig_publicroom", true);
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
multiUserChat.sendConfigurationForm(submitForm);
} catch (Exception e) {
e.printStackTrace();
}
}
Il problema è stato risolto ora, stavo chiamando il metodo setConfig() da un posto sbagliato. Dovrebbe essere chiamato dopo essere entrato nel gruppo. \t multiUserChat.join (nickname, password); // imposta la configurazione predefinita per la stanza \t \t \t \t \t setDefaultConfig (multiUserChat); –
Puoi rispondere alla tua domanda e accettarla. :) – iStar