xmpp android端退出失败(退出函数不对)

现在能够登录了,但是不能退出,就上网搜了搜,做了个退出函数,但是点击退出的时候报错:

虽然报这个错误,但是在openfire上用户的确还退出了,真神了。

上网各种搜啊,说这个错误怎么怎么样,怎么tm难整,经过一个小时的挣扎,最后注意到一个细节,我的退出函数是这么写的:

public static boolean PersonExit() {
		try {
			connection.getAccountManager().deleteAccount();
System.out.println("退出成功");
			return true;
		} catch (Exception e) {
System.out.println("退出失败");
			e.printStackTrace();
			return false;
		}
	}

这个getAccountManager.deleteAccount()为什么这么写,我看网上有的是直接disconnect掉就行了,结果一搜退出代码,加上自己改的:

try{
			if (connection != null) {
				connection.disconnect();
			}
			connection = null;
System.out.println("退出成功");
			return true;
		} catch(Exception e){
System.out.println("退出失败");
			e.printStackTrace();
			return false;
		}

这么写就行了。上网重搜之前的代码,大家都是这么写的,我都要哭了:

这到底是删除还是注销啊,是删除就不要写注销啊,而且网上代码都是互相转的,真是醉了。。。。。。。。。。。

posted @   融化的雪0701  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示