问题描述
- android中XMPP Asmack的问题
- 对XMPP Asmack不太熟,刚开始用
不知道怎么获取用户朋友的presence?(名单列表)
我用下面的代码实现:
Presence availability = roster.getPresence(user);Mode userMode = availability.getMode();
还要修改什么来获取用户的当前状态?
谢谢
解决方案
Presence availability = roster.getPresence(user);Mode userMode = availability.getMode(); retrieveState_mode(availability.getMode()availability.isAvailable()); public static int retrieveState_mode(Mode userMode boolean isOnline) { int userState = 0; /** 0 for offline 1 for online 2 for away3 for busy*/ if(userMode == Mode.dnd) { userState = 3; } else if (userMode == Mode.away || userMode == Mode.xa) { userState = 2; } else if (isOnline) { userState = 1; } return userState; }
如果还不能实现请告诉我。
解决方案二:
用这段代码:
userFromServer = con.getRoster().getPresence(userID);userState = retrieveState(userFromServer.getMode() userFromServer.isAvailable());public int retrieveState(Mode userMode boolean isOnline) { int userState = XmppFriend.OFFLINE; // default return value if (userMode == Mode.dnd) { userState = XmppFriend.BUSY; } else if (userMode == Mode.away || userMode == Mode.xa) { userState = XmppFriend.AWAY; } else if (isOnline) { userState = XmppFriend.ONLINE; } return userState;}
解决方案三:
返回的是在线或者不在线,怎么获得,申请状态,如subscribe,unsubscribe,unsubscribed?
时间: 2024-12-30 21:48:59