在 Android 中创建聊天室会出现错误:“item-not-found(404)
Posted
技术标签:
【中文标题】在 Android 中创建聊天室会出现错误:“item-not-found(404)【英文标题】:Creating Chat Room In Android Gives Error:"item-not-found(404) 【发布时间】:2013-04-18 07:20:35 【问题描述】:我正在使用 ASMACK 开发一个聊天应用程序。我可以连接并发送消息以进行私人聊天。但是,在尝试创建聊天室时出现错误:
item-not-found(404)
这是我正在使用的代码:
setConnection(connection);
if(connection != null)
try
// Smackandroid.init(this);
MultiUserChat muc=new MultiUserChat(connection,"chat1@groupchat.google.com");
muc.create("greatandroid");
Log.d("Chat Room Created","Successfully Created Chat Room");
Form form = muc.getConfigurationForm();
Form submitForm = form.createAnswerForm();
for (Iterator fields = form.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);
muc.sendConfigurationForm(submitForm);
Log.d("Config Form Created","Successfully Configured Chat Form");
catch(Exception ex)
Log.d("Error Creating Chat Room",ex.getMessage().toString());
我该如何解决这个问题?
【问题讨论】:
【参考方案1】:使用此代码
// Get the the room's configuration form
Form form = muc.getConfigurationForm();
// Create a new form to submit
// based on the original form
Form submitForm = form.createAnswerForm();
// Add default answers to the form
// to submit
for (Iterator fields = form.getFields(); fields.hasNext();)
FormField field = (FormField) fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType())
&& field.getVariable() != null)
// Sets the default value as
// the answer
//
submitForm.setDefaultAnswer(field.getVariable());
submitForm.setAnswer("muc#roomconfig_roomdesc", GroupName);
submitForm.setAnswer("muc#roomconfig_publicroom", false); //
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
//
submitForm.setAnswer("muc#roomconfig_membersonly", false);
//
submitForm.setAnswer("muc#roomconfig_allowinvites", true);
// JID
// submitForm.setAnswer("muc#roomconfig_whois", "anyone");
//
submitForm.setAnswer("muc#roomconfig_enablelogging", true);
//
// submitForm.setAnswer("x-muc#roomconfig_reservednick", true);
//
// submitForm.setAnswer("x-muc#roomconfig_canchangenick",
// false);
//
// submitForm.setAnswer("x-muc#roomconfig_registration", false);
// Send the completed form (with default values) to the
// server to configure the room
muc.sendConfigurationForm(submitForm);
【讨论】:
以上是关于在 Android 中创建聊天室会出现错误:“item-not-found(404)的主要内容,如果未能解决你的问题,请参考以下文章
无法在 android 中创建聊天室并从服务器(tigase 服务器)没有响应
我在 android 中创建 amazon coginto 后出现错误
如何在我的颤振应用程序中创建 android 固定的聊天快捷方式?
我们可以像在 android 中一样在 windows 中创建 XMPP 聊天客户端代码吗?