I have this code for managing some countrys on my database;
class checkCountryAsync extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
setContentView(R.layout.main);
}
@Override
protected String doInBackground(String... aurl) {
MDPIActivity.this.runOnUiThread(new Runnable() {
public void run() {
CountryTable country = new CountryTable() ;
country.EnterCountry();
}
});
return null;
}
}
With this, I would like to set the content View and then in background, that the method onBackground works, but I have still to wait for the content view until the onBackground method is not finished.
Thank you.
i don’t see any reason for putting the
setContentView()in theonPreExecutemethod, it should be in theonCreatemethod to avoid any kind ofNullPointerExceptionwhen you will try to find your views, and for yourAsyncTask, you should just use theonPostExecute()which is executed after the methoddoInBackground()