Issue
I am struck with this issue where, on getting a successful return from doInBackground, the onPostExecute is just not executed.
I read this StackOverflow answer which said that there is an issue with params. But, I am unable to figure out why. I have been running many AsyncTasks but have never encountered a problem as this. And other similiar SO answers doesn't help either.
Following is my code. Where I get values successfully in companyVO. Please help me solve this.
I feel it is something to do with parameters. Even the @Override annotation on postExecute shows error.
class companyCall extends AsyncTask<Void, Void, ArrayList<CompanyVO.ResultSet>> {
protected ArrayList<CompanyVO.ResultSet> doInBackground(Void...params) {
SharedPreferences prefrence = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String Token = prefrence.getString("token", "");
try {
WebserviceImpl webservices = new WebserviceImpl();
companyVO = webservices.getAllCompanyINfo(Token, getApplicationContext());
} catch (Exception e) {
Log.e("TAG", "Exception", e);
return null;
}
return companyVO;
}
protected void onPostExecute(CompanyVO.ResultSet result) {
if (result != null) {
Log.e("Done", "done"+result.getName());
} else {
Log.e("Error", "Not done");
}
}
}
Solution
You missed @Override
. So its not the overrided method also you have used different parameters. It should be as .
class CompanyCall extends AsyncTask<Void, Void, ArrayList<CompanyVO.ResultSet>> {
@Override
protected ArrayList<CompanyVO.ResultSet> doInBackground(Void...params) {
SharedPreferences prefrence = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
String Token = prefrence.getString("token", "");
try {
WebserviceImpl webservices = new WebserviceImpl();
companyVO = webservices.getAllCompanyINfo(Token, getApplicationContext());
} catch (Exception e) {
Log.e("TAG", "Exception", e);
return null;
}
return companyVO;
}
@Override
protected void onPostExecute(ArrayList<CompanyVO.ResultSet> result) {
if (result != null) {
Log.e("Done", "done"+result.getName());
} else {
Log.e("Error", "Not done");
}
}
}
Answered By - ADM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.