Reputation: 339
Android Studio is insisting that I am missing a return value in doInBackground
, even though it seems to be declared as Void
. Am I overlooking something?
AsyncTask<Boolean, Void, Void> initiateConnection = new AsyncTask<WebSocketClient, Void, Void>() {
@Override
protected Void doInBackground(WebSocketClient ... clients) {
clients[0].connect();
}
@Override
protected void onPostExecute(Void result) {
Log.i(st, "Socket connected.");
}
};
initiateConnection.execute();
}
Upvotes: 1
Views: 1886
Reputation: 9996
You need to return null
protected Void doInBackground(WebSocketClient ... clients) {
clients[0].connect();
return null;
}
Upvotes: 2
Reputation: 1006809
Void
(uppercase V
) is not void
(lowercase v
). With void
, you can just "fall off the bottom of the method". With Void
, you need to explicitly return something, typically null
.
Upvotes: 9