Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Created October 27, 2011 22:00
Show Gist options
  • Save jbrechtel/1321013 to your computer and use it in GitHub Desktop.
Save jbrechtel/1321013 to your computer and use it in GitHub Desktop.
AsyncTask
public void onClick(View v) {
new DownloadImageTask().execute("http://example.com/image.png");
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}
protected void onPostExecute(Bitmap result) {
mImageView.setImageBitmap(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment