Use
new Thread() {
public void run() {
final String data = getServerData(KEY_121);
if (data != null)
runOnUiThread(new Runnable()
{
public void run()
{
txt.setText(data);
}
});
}
}.start();
Instead of:
//call the method to run the data retreival
txt.setText(getServerData(KEY_121));
You cannot run long tasks on the main thread. But you have to use the UI thread to set the text.