Reputation: 13143
I want to run a task that would accept a single string and download that file from the server. Since network related operations have to be performed on the different thread I have to extend AsyncTask. Referring the online doc I see that it takes three parameters i.e Params, Progress and Result.
I understand that it makes sense to extend a class like this
private class DownloadFileTask extends AsyncTask<URL, Integer, Long>
But right now I just want to download the file and not show any progress or return anything from the function.
extending a class like this gives me error
private class DownloadFileTask extends AsyncTask<String, void, void>
{
protected void doInBackground(Sting url)
{ //code to simply download file , no progress shown , nothing returned
}
}
I also understand as an implementing class DownloadFileTask show override the method
protected abstract Result doInBackground (Params... params)
the Result in its prototype is the third parameter of AsyncTask<...> Template. So I cant have that as void. But isnt there a way to simply download file without showing progress and result?
Upvotes: 0
Views: 685
Reputation: 16043
The generic arguments should be objects, so you should pass Void
instead of void
.
....extends AsyncTask<String, Void, Void>
Upvotes: 3