Skip to content

Instantly share code, notes, and snippets.

View laszlo-galosi's full-sized avatar

László Gálosi laszlo-galosi

  • Budapest, Hungary
View GitHub Profile
@laszlo-galosi
laszlo-galosi / CountingImageDownloader
Created March 28, 2016 13:25
Bitmap downloader AsyncTask with determinate progress and counter.
@Override
protected Bitmap doInBackground(String... urls) {
Bitmap bitmap = null;
try {
HttpURLConnection connection = (HttpURLConnection) new URL(urls[0]).openConnection();
connection.setRequestProperty("User-agent", "Mozilla/4.0");
connection.setRequestMethod("GET");
connection.connect();
InputStream in = null;
int responseCode = connection.getResponseCode();