title: Getting Presence unavailable, status null of all roster
body: <p>I am creating a <strong>XMPP</strong> Android chat client with <a href="https://github.com/flowdalic/asmack" rel="nofollow"><strong>asmack</strong> library</a> and <strong>Openfire</strong> server.</p>
  
  <p>I want to get the presence of all the roster from my roster list and display all online roster's, but when I check the Presence of roster it gives me unavailable for all the roster and status is null.</p>
  
  <p>Below is my code how I am creating a roster and check for presence?</p>
  
  <p><strong>setting Presence</strong> </p>
  
  <pre><code>Presence presence = new Presence(Presence.Type.available);
  presence.setStatus("I’m available");
  connection.sendPacket(presence);
  </code></pre>
  
  <p><strong>Get Roster List and check for presence</strong></p>
  
  <pre><code>Collection&lt;RosterEntry&gt; entries = roster.getEntries();
  Log.e("Roster Entries","Roster Entries"+entries);
  //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();
      int state = retrieveState_mode (entryPresence.getMode()         ,entryPresence.isAvailable());
      Log.e("Presence Status","Presence status "+entryPresence.toString()+"  type  "+userType+"  mode  "+mode+"  status "+status+" state "+state);
  }
  </code></pre>
  
  <p><strong>retriveState_mode()</strong></p>
  
  <pre><code>public static int retrieveState_mode(Presence.Mode userMode, boolean isOnline) {
      int userState = 0;
      /** 0 for offline, 1 for online, 2 for away,3 for busy*/
      if(userMode == Presence.Mode.dnd) {
          userState = 3;
      } else if (userMode == Presence.Mode.away || userMode == Presence.Mode.xa) {
          userState = 2;
      } else if (isOnline) {
          userState = 1;
      }
      return userState;
  }
  </code></pre>
  
  <p>In log I get this:</p>
  
  <pre><code>Roster Entries﹕ Roster Entries[tusha: tusha, tushar: tushar]
  Presence status unavailable  type  unavailable  mode  null  status null state 0
  Presence status unavailable  type  unavailable  mode  null  status null state 0
  </code></pre>