title: How to Create a XMPP Chat Client in Android with Openfire?
body: <p>I am a newbie to Android. I wanted to create a XMPP chat client along with push notifications. I have installed openfire and the server is ready for testing on my local machine.</p>
  
  <p>At this point what I am doing
  1. Creating a XMPP connection in ASYNC task
  2. onPost creating a chat manager</p>
  
  <pre><code>protected void onPostExecute(final Boolean success) {
          if (success) {
              if (connection != null) {
                  chatManager = connection.getChatManager();
                  Chat newChat = chatManager.createChat("shobhit",
                           new MessageListener() {
                              public void processMessage(Chat chat, Message message) {
  //Do something
                              }
                          });
              }
          }
      }
  </code></pre>
  
  <p>But I am totally confused if I am doing this is correctly. I read somewhere on stackoverflow that ASYNC should be used only for small duration activities and my connection can get timed out here.</p>
  
  <p>I also found these as probable solutions:
  Runnable, Handlers
  Create a Service
  Broadcast receivers</p>
  
  <p>I am not sure which method should I opt. Can you guys suggest the optimum method and pointers to the example of that would be great?</p>
  
  <p>Thanks
  Chetan</p>