runOnUiThread from service to Activity
<p>I have a method "send()" that send values to the server and then get response 0 or 1 from the server. then i want to active a method that check if its 0 or 1 and then i want to active a method that on MainActivity that called from the service.</p>

<p><strong>this is the service code</strong></p>

<pre><code>    public class SendThreadCommunication extends Thread {
private final static String TAG = "SendThreadCommunication";
private final int READ_TIMEOUT = 100000;
private final int CONNECTION_TINEOUT = 100000;
private Looper myLooper;
private int mResponseCode;
private String mData = "";

private final ServerRequest req;
// private RegisterUser user;
private static String ans;

public SendThreadCommunication(ServerRequest req) {

    this.req = req;
}

public String readWebData(InputStream stream) {

    String line = "";
    StringBuffer buffer = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

    try {
        while ((line = reader.readLine()) != null) {
            buffer.append(line);
        }
        reader.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block

    }
    return buffer.toString();

}

@Override
public void run() {
    try {
        send();
       // evaluateDataAndRespondToFragment(mData);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}


public void send() throws ClientProtocolException, IOException {
    OutputStream mOutputStream = null;
    BufferedWriter mWriter = null;

    List&lt;NameValuePair&gt; mParameters = req.getParameters();

    URL url = null;
    HttpURLConnection connection = null;
    try {
        Looper.prepare();
        url = new URL(req.returnRequestUrl());
        connection = (HttpURLConnection) url.openConnection();
        connection.setReadTimeout(READ_TIMEOUT);
        connection.setConnectTimeout(CONNECTION_TINEOUT);
        connection.setRequestMethod(Params.HTTP_REQUEST_METHOD_POST);
        connection.setDoOutput(true);
        connection.setDoInput(true);
        mOutputStream = connection.getOutputStream();
        mWriter = new BufferedWriter(new OutputStreamWriter(mOutputStream, Params.UTF8));
        String sparams = URLEncodedUtils.format(mParameters, Params.UTF8);
        mWriter.write(sparams);
        mWriter.flush();

        mResponseCode = connection.getResponseCode();
        if (mResponseCode &gt; 203) {
            mData = readWebData(connection.getErrorStream());
            //this.req.getResponse().notGoodServerEroorr();
        } else {
            mData = readWebData(connection.getInputStream());

        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        if (connection != null) {
            try {
                if (mOutputStream != null)
                    mOutputStream.close();
                if (mWriter != null)
                    mWriter.close();

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            connection.disconnect();
            evaluateDataAndRespondToFragment(mData);
            myLooper = Looper.myLooper();
            Looper.loop();
            myLooper.quit();

        }
    }
  }

private void evaluateDataAndRespondToFragment(String mData) {
    Listen lis = this.req.getResponse();

    if (mData.equals("1"))
        lis.good();
    else
        lis.notGood();

     if (mData.equals("0"))
     {
         lis.userGcmNotRegistered();
     }
    }
 }
</code></pre>

<hr>

<p>this service code send to the server values and get response. the method "evaluateDataAndRespondToFragment" check if its 0 or 1 and then active the appropriate method. that method should trigger other method in the MainActivity.
i know that <strong>runOnUiThread</strong> handle this, but i dont know how to use it.
the method on the MainActivity change the UI.</p>

<p><strong>this is the MainActivity code</strong></p>

<pre><code>  public class MainActivity extends Activity implements SensorEventListener, Listen {

private BroadcastReceiver statusReceiver;
private IntentFilter mIntent;
Sensor accelerometer;
SensorManager sm;
TextView acceleration;
SendValues sv;
int counter3 = 0;
int counter5 = 0;
int pastTime = 0;

private static final String TAG = "MainActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    }


@Override
public void good() {
    Toast.makeText(getApplication(), "successful transfer", Toast.LENGTH_LONG).show();
}

@Override
public void notGood() {
    Toast.makeText(getApplication(), "UNsuccssful transfer", Toast.LENGTH_LONG).show();
}

@Override
public void userGcmNotRegistered() {
    Toast.makeText(getApplication(), "There is some problem, please register again to the App", Toast.LENGTH_LONG).show();
  }

}
</code></pre>

<hr>

<p>Here it should active one of the methods "good","not good"....
i know that <strong>runOnUiThread</strong> handle it but i dont know how to use it and where.
if anyone could tell me what to do i will appreciate.</p>