title: Pass data from thread to activity
body: <p>In my application I have an activity that starts a thread</p>
  
  <pre><code>connectThread = new ConnectThread(MainActivity.this , device);
  connectThread.start();
  </code></pre>
  
  <p>in this thread  2 things are done :
  1. a new thread is created 2. and a new activity is started</p>
  
  <pre><code>connectedThread = new ConnectedThread(mmSocket);
  connectedThread.start();
  
      handler.post(new Runnable() {
  
          @Override
          public void run() {
              MainActivity.connectingProgressBar.setVisibility(View.GONE);
  
              Intent startPostGet = new Intent(context, PostGetActivity.class);
              startPostGet.putExtra(MainActivity.EXTRA_DEVICE, mmDevice);
              context.startActivity(startPostGet);                
          }
      });
  </code></pre>
  
  <p>in the latest created thread (connectedthread) I receive data and want to pass this to the newest activity (postgetactivity)</p>
  
  <p>i was thinking about doing something like this in the connectedthread:</p>
  
  <pre><code>handler.post(new Runnable() {
          @Override
          public void run() {
              PostGetActivity.statusTextView.setText("Got data");
              PostGetActivity.processData(data)
          }
      });
  </code></pre>
  
  <p>The problem is that the function processData() may not be static but I am referencing it from a static context. </p>
  
  <p>How can I fix this? Any help will be appreciated.</p>