title: Asynchronous communication in android
body: <p>I am trying to integrate apacahe Mina in android.</p>
  
  <p>Can we persist objects using AsyncTask &amp; pass to UI or another class for further use?</p>
  
  <p>for example</p>
  
  <pre><code>public class NetworkConnect extends AsyncTask&lt;String, Void, String&gt;{
  
          @Override
          protected String doInBackground(String... param) {
  
                   Protocol p = new Protocol(); //here I m making connection with echo server
                   //Now I want that session in UI to send messages to echo Server
          }
  }
  </code></pre>
  
  <p>I want to use this 'p' instance in other class(Like UI) and using this 'p' instance  call to attributes of Protocol class.
  How to do that? or Is there any alternative solution?
  Basically 'Protocol' class should run parallel to UI thread and based on events both should be able to communicate with each other.</p>
  
  <p>Suppose there is echo server...then when someone enter input to 'Input' edittext and hit 'send' button, echoServer will give me back this 'input' again. 
  Now my problem is that using AsyncTask I am able to connect server, But I am unable to using same session in UI. So I can't send data to server.</p>
  
  <p>Thank you</p>