Created
September 21, 2011 09:50
-
-
Save jgilfelt/1231694 to your computer and use it in GitHub Desktop.
Android - AsyncTask with inline callback boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void asyncTaskWithInlineCallback() { | |
// display UI progress indicator | |
// ... | |
new MyAsyncTask() { | |
protected void onPostExecute(Boolean result) { | |
// dismiss UI progress indicator | |
// process the result | |
// ... | |
} | |
}.execute(); // start the background processing | |
} | |
class MyAsyncTask extends AsyncTask<Void, Integer, Boolean> { | |
@Override | |
protected Boolean doInBackground(Void... arg0) { | |
// do background processing and return the appropriate result | |
// ... | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much! I was searching for answer like this for ages! Very helpful indeed.