Java: Invalid type 'void' in ASyncTask

I hope you can light this light for me.

I am trying to create the following AsyncTask in Java for an Android application. When I enter the code below, Android Studio allocates both void parameters with an error:

"Invalid type: Void."

After a few google searches, I still can't figure out what the problem is here (and to be honest, I'm completely confused by all of this!)

private class BackgroundTask extends AsyncTask<URL, void, void> { protected void doInBackground(URL... inputURL) { URL searchURL = inputURL[0]; //Step 2: Get Data String JSONdata = getJSONdata(searchURL); //Step 3: Parse JSON ArrayList books = parseJSON(JSONdata); updateUI(books); } } 

Appreciate any information you can send to me.

+5
source share
2 answers

use capital class V instead

 private class BackgroundTask extends AsyncTask<URL, Void, Void> { 
+7
source

AsyncTask uses generics. Therefore use Void instead of void . Similarly, if you want to use integer, use Integer , not int .

+6
source

All Articles