I have been using this AsyncTask for couple of projects, but still don't quite get what does <String, Void, String>
mean. Do these mean the parameter types of the unimplemented methods? are there any orders(what are the method corresponds to String, Void, String respectively)?
From Android Docs AsyncTask page:
android.os.AsyncTask<Params, Progress, Result>
The three types used by an asynchronous task are the following:
Params, the type of the parameters sent to the task upon execution.
Progress, the type of the progress units published during the background computation.
Result, the type of the result of the background computation.
Now my understanding in simple words:
Params: (in your case String) is the parameter that the AsyncTask
takes. You have to pass this when you call execute
method
Progress: (in your case Void) is the type of progress. Void means you are not using it. If it is say, Integer, you could've used values like 10, 20, 30... and use these to show a progress bar on screen.
Result: (in your case String) is what the AsyncTask
returns as the result. You are returning a String. You can return any Object you want.
So simply put, it is somewhat like a method where Params are parameters, Result is return type and progress tells you status of processing progress.
For further understanding see this tutorial, also quote from the same page may be helpful:
AsyncTask<TypeOfVarArgParams, ProgressValue, ResultValue>
TypeOfVarArgParams is passed into the doInBackground() method as input, ProgressValue is used for progress information and ResultValue must be returned from doInBackground() method and is passed to onPostExecute() as parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With