Skip to content

Instantly share code, notes, and snippets.

@takuo takuo/gist:1294791
Created Oct 18, 2011

What would you like to do?
Android code snippet - using AsyncTask
public void onClick(View v) {
new DownloadImageTask().execute("");
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
/** The system calls this to perform work in a worker thread and
* delivers it the parameters given to AsyncTask.execute() */
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
/** The system calls this to perform work in the UI thread and delivers
* the result from doInBackground() */
protected void onPostExecute(Bitmap result) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.