July 2015
Beginner to intermediate
600 pages
18h 59m
English
In this chapter you saw how to use the last type parameter on AsyncTask, which specifies the return type. What about the other two?
The first type parameter allows you to specify the type of input parameters you will pass to the execute(), which in turn dictates the type of input parameters doInBackground(…) will receive. You would use it in the following way:
AsyncTask<String,Void,Void> task = new AsyncTask<String,Void,Void>() {
public Void doInBackground(String... params) {
for (String parameter : params) {
Log.i(TAG, "Received parameter: " + parameter);
}
return null;
}
};
Input parameters are passed in to the execute(…) method, which takes in a variable number of arguments:
task.execute("First ...Read now
Unlock full access