William H Taylor wrote:private class WeatherTask extends AsyncTask<String, Void, Weather> {
@Override
protected Weather doInBackground(String... params) {
I got these two questions about the asynctask three types in one and the string ... parameters, I never saw these before. Can someone explain it to me. I was reading through java code and I don't know how to look these up. I think they are Generics but I never saw generics with three types. I also never saw java with a variable set of method parameters. I appreciate the help.
It is really easy. Under Android the Google Developers preferred to manage background services with more performing tools, so they built AsyncTask as an "helper" for short operations.
You have to look up 2 things the parameters inside the diamond brackets and the methods. I can recognize your code is the one released by google for their udacity course.
It is quite complex, because it is connected to JSON backend, I would suggest you to type yourself a simpler example, focusing on the first parameter called Params that will be passed to the method doInBackground(Params...) and you can leave the other two parameters Void ex <String, Void, Void>. Just remember that you need to call the AsyncTask instance to activate AsyncTask.