Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 以匿名用户ASMACK XMPP ANDROID身份登录_Java_Android_Xmpp_Asmack - Fatal编程技术网

Java 以匿名用户ASMACK XMPP ANDROID身份登录

Java 以匿名用户ASMACK XMPP ANDROID身份登录,java,android,xmpp,asmack,Java,Android,Xmpp,Asmack,如何在android中使用匿名用户ASMACK library for XMPP登录我的服务器 我正在使用OpenFire服务器 现在,我正在使用以下代码进行自我登录: String host = "web.xyz.com"; //getText(R.id.host); String port = "5222"; //getText(R.id.port); String service = "web.xyz.com";//getText(R.id.service); String userna

如何在android中使用匿名用户ASMACK library for XMPP登录我的服务器

我正在使用
OpenFire
服务器

现在,我正在使用以下代码进行自我登录:

String host = "web.xyz.com"; //getText(R.id.host);
String port = "5222";  //getText(R.id.port);
String service = "web.xyz.com";//getText(R.id.service);
String username = Register.username; //getText(R.id.userid);
String password = Register.pass; //getText(R.id.password);

ServiceProvider.Register_Providers(ProviderManager.getInstance());
// Create a connection
connConfig = new ConnectionConfiguration(host, Integer.parseInt(port),service);
connection = new XMPPConnection("host");

try {
    connection.connect();
    Log.i("XMPPClient", "[SettingsDialog] Connected to " + connection.getHost());
} catch (XMPPException ex) {
    ex.printStackTrace();
    Log.e("XMPPClient", "[SettingsDialog] Failed to connect to " + ex.getMessage());
    Register.setConnection(null);
}
try {
    connection.login(username, password);
    Log.i("XMPPClient", "Logged in as " + connection.getUser());

    // Set the status to available
    Presence presence = new Presence(Presence.Type.available);
    connection.sendPacket(presence);
    Register.setConnection(connection);
} catch (XMPPException ex) {
    Log.e("XMPPClient", "[SettingsDialog] Failed to log in as " + username);
    Register.setConnection(null);
}

如果您想登录,您必须在服务器上启用匿名连接,并且您不需要提供用户名和密码,只需使用而不是
login()

您使用什么?明火?ejabberd?您是否配置了本地服务器和用户凭据?像ejjaberd、quickblox等服务器。是的,我使用的是openfire服务器。我可以用已经在服务器上注册的用户名和密码登录。但是我不能匿名登录Lysee,xmpp/openfire为我们提供了这个工具,可以通过服务器匿名登录。我想匿名登录我自己