原问题来自于CSDN问答,更多解决方案见;http://ask.csdn.net/questions/1204
原问题:
不知道怎么获取用户朋友的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 away,3 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; }