Search code examples
androidrequestconnectionquickblox

Quickblox Android : Get status of connection request sent


I am using Quickblox for chatting application in Android. I have sent friend / connection request to any person I want status of that request i.e. weather it is accepted or pending?

QBRoster chatRoster;
chatRoster.subscribe(userID);

Reference : http://quickblox.com/developers/Android_XMPP_Chat_Sample#Contact_list

Please help.


Solution

  • Answer for the question is

    QBRoster roster;
    Collection<QBRosterEntry> entries
    QBRosterEntry rosterEntry = roster.getEntry(holder.userid);
    boolean isSubscribedToUser = rosterEntry.getType() == RosterPacket.ItemType.from;
    boolean isBothSubscribed = rosterEntry.getType() == RosterPacket.ItemType.both;
    QBPresence presence;
    for (QBRosterEntry entry : entries)
    {
        presence = roster.getPresence(entry.getUserId());
        System.out.println(entry.getStatus());//online/offline
        System.out.println(presence.getType().name());
    }
    boolean ispendingFreindRequest=RosterPacket.ItemStatus.subscribe.equals(rosterEntry.getStatus());
    String stausRelationaship=RosterPacket.ItemType.none.name();
    

    Note roster should not be null. Initialize it after successfully creating session and user login.