Reputation: 8717
Why is this not valid according to eclipse:
protected String doInBackground(String... arg0) {
publishProgress(10);
if(true){
//validate with DB
}else{
//send to registration screen
}
return null;
}
//Update Progress
protected void onProgressUpdate(Integer... values) {
mProgress.setProgress(values[0]);
}
Eclipse is saying this:
publishProgress(10); <<publishProgress(Void) is not acceptable for type publishProgress(Int)
However other questions on here show it used in that exact way. Is it a change in the API? I really want to pass publishProgress a string and and int. Is this possible:
publishProgress("Starting Validation", 10);
TIA
Upvotes: 1
Views: 4922
Reputation: 117627
Make sure you are declaring the right type in the generic parameters, something like:
new AsyncTask()<Void, Integer, Void>{ ...
AsyncTask<Params, Progress, Result>
:
doInBackground()
's and execute()
var-args parameters.publishProgress()
's and onProgressUpdate()
's var-args parameters.doInBackground()
's return value, onPostExecute()
's parameter, onCancelled()
's parameter, and get()
's return value.Upvotes: 17