For the More Curious: More on AsyncTask

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:

A​s​y​n​c​T​a​s​k​<​S​t​r​i​n​g​,​V​o​i​d​,​V​o​i​d​>​ ​t​a​s​k​ ​=​ ​n​e​w​ ​A​s​y​n​c​T​a​s​k​<​S​t​r​i​n​g​,​V​o​i​d​,​V​o​i​d​>​(​)​ ​{​ ​ ​ ​ ​p​u​b​l​i​c​ ​V​o​i​d​ ​d​o​I​n​B​a​c​k​g​r​o​u​n​d​(​S​t​r​i​n​g​.​.​.​ ​p​a​r​a​m​s​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​f​o​r​ ​(​S​t​r​i​n​g​ ​p​a​r​a​m​e​t​e​r​ ​:​ ​p​a​r​a​m​s​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.