March 2013
Beginner to intermediate
580 pages
16h 11m
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 your input parameters. 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;
}
};
task.execute("First parameter", "Second parameter", "Etc.");
Input parameters are passed in to the execute(…) method, which takes in a variable number of arguments. Those variable arguments are then passed on to doInBackground(…).
The second ...
Read now
Unlock full access