I'm trying to implement a thread on a function that starts an HttpClient because it's recomended according to d.android.com So I have implemented a thread but, it doesn't seem to run as if I remove the thread code I see results.
This is my code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chat_box);// sd
TextView inbox = (TextView) findViewById(R.id.inbox);
final Functions function = new Functions();
final SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
where = prefs.getString("chat", "null");
class SendThread extends Thread {
public void run(){
//getInbox() runs an http client
listOfMessages = function.getInbox(where);
}
}
SendThread sendThread = new SendThread();
sendThread.start();
inbox.setText(listOfMessages);
}
Like I said above, if I remove my thread code, then it works perfectly. Any ideas on what I'm doing wrong? This is my first time using threads, sorry for any rookie mistakes.
I don't get any errors (at least I don't see any) but, I don't see the output that I get without the thread code inserted.
inbox.setText(listOfMessages)is probably executed beforelistOfMessages = function.getInbox(where);.