Generally I update UI in postExecute method.
e.g.
public class SampleActivity extends Activity{
TextView textSample;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aadd_addtocheck);
textSample = (TextView) findViewById(R.id.lin);
STask sampleTask = new Stask();
sampleTask.execute();
}
class GetAdd extends AsyncTask<Void, Void, JSONObject> {
@Override
protected JSONObject doInBackground(Integer... params) {
// TODO Auto-generated method stub
UserFunctions u = new UserFunctions();
return u.getNewAdd();
}
@Override
protected void onPostExecute(JSONObject result) {
super.onPostExecute(result);
textSample.setText(result.getString("Something");
}
However, my asyncTask become large and I want to move them to different class (before they were a subclass). Therefor, I wonder how to to update UI ( like setting texviews) when asynctask will be a separete class.