The Return Type Is Incompatible With Asynctask
I'm trying to capture the response of httpclient using AsyncTask but throws me the following error verifying any incompatibility doInBackground in the String: 'the return type is
Solution 1:
the problem here is that AsyncTask Extensions are generic and need three types: AsyncTask<Params, Progress, Result>
AsyncTask which may be Void or a class, but not primitive data types.
so what happens is you told the compiler that doInBackground returns a primitive var but it was expecting an instance of the class String
.
So use doInBackground
function as
@OverrideprotectedStringdoInBackground(String... params) {
// TODO Auto-generated method stubString result = insertar();
return result;
}
Edit
In AsyncTask you are returning Boolean
and in doInBackground return type is String
,so
change it to String
because you want String value from insertar()
function,i.e. change
classInsertarextendsAsyncTask<String,String,Boolean>{
to
classInsertarextendsAsyncTask<String,String,String>{
and
@OverrideprotectedvoidonPostExecute(Boolean result) {
}
to
@OverrideprotectedvoidonPostExecute(String result) {
}
Post a Comment for "The Return Type Is Incompatible With Asynctask"