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);
updateUI(books);
}
}
Appreciate any info you can send my way!
use the class instead, capital V
private class BackgroundTask extends AsyncTask<URL, Void, Void> {
AsyncTask uses generics. So use Void instead of void. Similarly, if you want to use integer use Integer and not int.
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