0
votes

I am trying to implement android chat application by using XMPP(aSmack).I check my code are correct are okay for login ,registration.Now i am trying to get all user information (offline/online/away/etc.) I try to used by Presence.But i can't success.When the xmpp connection are okay and user login success then i call the Presence by

if (connection != null && connection.isConnected()) {
        Presence presence = new Presence(Presence.Type.available);
        presence.setStatus("I’m available");
        connection.sendPacket(presence);
        Log.w("type", "I’m available");
    }

After calling this function then i try to get all user information .My Roster code are:

    Roster roster = connection.getRoster();
    // Get all rosters
    Collection<RosterEntry> entries = roster.getEntries();
    Log.w("Size ", "are"+entries.size());
    // loop through
    for (RosterEntry entry : entries) {
        // example: get presence, type, mode, status
        Presence entryPresence = roster.getPresence(entry.getUser());
        Presence.Type userType = entryPresence.getType();
        Presence.Mode mode = entryPresence.getMode();
        String status = entryPresence.getStatus();

        Log.w("mode ", "are"+mode);
        Log.w("status ", "are"+status);
        Log.w("mode ", "are"+entryPresence.isAvailable());
    }

But my problem,All the time i get one entries size,who i am.without my mode show all the time false(That means i am unavailable).I don't understand what it the problem.I need work on server config. again.or My code are wrong.Please help to me how i can solve those two issues.Thanks all.

1
Which aSmack version do you use?Flow
Hello@Flow thanks to your reply.i used asmack-android-8-0.8.10.jar .Any problem for using this version.?Prosanto
I don't know, but 4.0.6 is the latest stable aSmack as of now. You may want to consider updating.Flow
Hello@ thanks your ans.Can you give to specific link where i get the version and How i solve my issue.Roster created but all time Presence get "unavailable".Prosanto

1 Answers

0
votes

You can get all roster from server by using connection object

Roster roster = mConnection.getRoster();

where mConnection is the xmpp connection object. You should also add roster listener to the roster object.

For more information you can refer to this link.