I am tring to setText in another thread, that is, child thread. But for the following code, it is giving the error
Only the original thread that creat
Use runOnUiThread for updating the UI control. In your case:
runningActivity.runOnUiThread(new Runnable() {
public void run() {
tv.setText(p + " %");
}
});
Edited:
Activity mActivity;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mActivity= this;
...
..//The rest of the code
} //close oncreate()
thread{
mActivity.runOnUiThread(new Runnable() {
public void run() {
tv.setText(p + " %");
}
});
}