Caphson Caphson - 1 year ago 172
Android Question

Java: Illegal type 'void' in ASyncTask

Hopefully you can shine some light on this for me.

I'm trying to create the following AsyncTask in Java for an Android app. When I enter the below code, Android Studio highlights both the 'void' params with the error:

"Illegal Type: Void".

After a number of google searches I still can't understand what the problem is here (and in honesty, I'm quite confused about the whole thing!).

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);



Appreciate any info you can send my way!

Answer Source

use the class instead, capital V

private class BackgroundTask extends AsyncTask<URL, Void, Void> {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download