title: Why when the XMPP connection disconnect the presence type user change from unavailable to available
body: <p>How to log out correctly when I close the application and stop the ping execute?</p>
  
  <p>When I run the logout below each line code work perfect,</p>
  
  <p>But if I run the code lines:</p>
  
  <pre><code> Presence presence = new Presence(org.jivesoftware.smack.packet.Presence.Type.unavailable);
              presence.setStatus(connection.getUser() + status);
              connection.sendPacket(presence);
  </code></pre>
  
  <p>I get user offline/unavailable.<code>//But the connection alive</code></p>
  
  <p>Then I want to disconnect the connection so I run the line code.</p>
  
  <pre><code>connection.disconnect();//I get user online/available and connection die.
  </code></pre>
  
  <p>I have more one problem when the connection die i get something like ping.</p>
  
  <pre><code>11-13 21:55:02.820: D/SMACK(7399): 09:55:02 PM SENT (1385370112):  
  11-13 21:55:32.820: D/SMACK(7399): 09:55:32 PM SENT (1385370112):  
  11-13 21:56:02.820: D/SMACK(7399): 09:56:02 PM SENT (1385370112):  
  11-13 21:56:32.820: D/SMACK(7399): 09:56:32 PM SENT (1385370112):  
  11-13 21:57:02.820: D/SMACK(7399): 09:57:02 PM SENT (1385370112):  
  11-13 21:57:32.820: D/SMACK(7399): 09:57:32 PM SENT (1385370112):  
  11-13 21:58:02.824: D/SMACK(7399): 09:58:02 PM SENT (1385370112):  
  11-13 21:58:32.824: D/SMACK(7399): 09:58:32 PM SENT (1385370112):  
  11-13 21:59:02.824: D/SMACK(7399): 09:59:02 PM SENT (1385370112):  
  11-13 21:59:32.824: D/SMACK(7399): 09:59:32 PM SENT (1385370112): 
  </code></pre>
  
  <hr>
  
  <pre><code>public void logOut(boolean unavailable, String status) {
  
      if (isConnectionAlive() || reConnectAndAuth()) {
          Presence presence = new Presence(org.jivesoftware.smack.packet.Presence.Type.unavailable);
          presence.setStatus(connection.getUser() + status);
          connection.sendPacket(presence);
          pm = null;
          connection.disconnect();
         //iscNNcet();
          Log.w("LogOut","LogOut");
      }
  }
  </code></pre>