gpt4 book ai didi

java - Android - XMPPError : jid-malformed - modify

转载 作者:太空宇宙 更新时间:2023-11-04 11:05:25 24 4
gpt4 key购买 nike

我正在使用 smack-android:4.1.0 进行聊天,我正在使用 openfire。当我尝试在 android 中使用 AccountManager 创建帐户时,我遇到 jid-malformed 我已经尝试了所有方法,但无法找到解决方案,我正在使用我的代码来创建用户。

if(connection != null && connection.isConnected()){
Log.e("=AccountManager= ","AccountManager");

// Registering the user
AccountManager accountManager = AccountManager.getInstance(connection);
//Log.e("=supportsAccountCreation= ","="+accountManager.supportsAccountCreation());
//Log.e("=getAccountInstructions= ","="+accountManager.getAccountInstructions());
Map<String, String> attributes = new HashMap<>();
attributes.put("email", "kanta@signitysolutions.in");
attributes.put("username", "spota421");

if (accountManager!=null&&accountManager.supportsAccountCreation()) {
accountManager.sensitiveOperationOverInsecureConnection(true);
accountManager.createAccount("spota421", "xxxxx", attributes);
}


}

下面是我在控制台中得到的响应,请任何人指导我,我做错了什么。

 D/SMACK: SENT (0): <iq to='52.62.104.135:9090' id='4Clc6-3' type='get'><query xmlns='jabber:iq:register'></query></iq>
10-02 07:40:21.670 7216-7330/
D/SMACK: RECV (0): <iq type="error" id="4Clc6-3" to="ip-172-31-28-121.ap-southeast-2.compute.internal/8xk12y6kvq" from="52.62.104.135:9090"><query xmlns="jabber:iq:register"/><error code="400" type="modify"><jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>


org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: jid-malformed - modify
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at org.jivesoftware.smackx.iqregister.AccountManager.getRegistrationInfo(AccountManager.java:332)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at org.jivesoftware.smackx.iqregister.AccountManager.supportsAccountCreation(AccountManager.java:144)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at com.signity.spota.xmpp.CreateConnection.Authenticate(CreateConnection.java:182)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at com.signity.spota.xmpp.CreateConnection.access$200(CreateConnection.java:34)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at com.signity.spota.xmpp.CreateConnection$connect.onPostExecute(CreateConnection.java:121)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at com.signity.spota.xmpp.CreateConnection$connect.onPostExecute(CreateConnection.java:55)
10-02 07:40:21.675 7216-7216/com.signity.spota W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:636)

最佳答案

试试这个,希望它能起作用。

     if (XMPPConnection != null && XMPPConnection.isConnected()) {
Log.e("=AccountManager= ", "AccountManager");

AccountManager accountManager = AccountManager.getInstance(XMPPConnection);

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

try {
if (accountManager != null && accountManager.supportsAccountCreation()) {
accountManager.sensitiveOperationOverInsecureConnection(true);
Jid jid = JidCreate.entityBareFrom("spot123" + "@" + "yourOpenFireService As String");
accountManager.createAccount(jid.getLocalpartOrNull(), "Spot1234sdfsd", attributes);
}
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (XmppStringprepException e) {
e.printStackTrace();
}


}

关于java - Android - XMPPError : jid-malformed - modify,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46524916/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com