title: Update list and adapter from outer class
body: <p>I am building a chat app.In <code>Oncreate</code> I am connecting to my server with this method:</p>
  
  <pre><code>public void connectToJabber(String username,String password) {
      Intent jService=new Intent(this,ConnectionIntent.class);
      jService.putExtra("type", "login");
      jService.putExtra("username",username);
      jService.putExtra("password",password);
      startService(jService);
  }
  </code></pre>
  
  <p>You see,this is a service.This is my <code>ConnectionIntent</code> service:</p>
  
  <pre><code>    protected void onHandleIntent(Intent intent) {
          final Connection connection=((Trackers)getApplication()).getConnectionInstance();
          String process=intent.getExtras().getString("type");
  
          if (process.equals("login") == true) {
              //Login İşlemleri
              String username=intent.getExtras().getString("username");
              String password=intent.getExtras().getString("password");
              try {
                  connection.login(username,password);
              } catch (XMPPException | SmackException | IOException e) {
                  e.printStackTrace();
              }
          }
  ...
  </code></pre>
  
  <p>You see I am using <code>connection</code> variable for connect.And I am getting this variable from <code>Connection</code> class.</p>
  
  <p>In <code>Connection</code> class I have a message listener class.When I receive a message it is coming to this method:</p>
  
  <pre><code>    public class ListenMessages implements MessageListener {  
          @Override
          public void processMessage(Chat arg0,
                  org.jivesoftware.smack.packet.Message arg1) {
              System.out.println(String.format("Received message:"+arg1.getBody()));  
  
          }  
  
      } 
  </code></pre>
  
  <p>My problem is starting here.When I receive the message I have to add sender's name to chat list and I should update the adapter.But I defined chat list and adapter inside main activity.So I couldn't access it from <code>processMessage</code>.</p>
  
  <p>What should I do for achive this ?</p>