Created
September 7, 2011 15:54
-
-
Save rsaunders100/1200952 to your computer and use it in GitHub Desktop.
(Android) The basic structure of Android's Async task.
This file contains hidden or 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
public class ExampleAsyncTask extends AsyncTask<Void, Void, ResultObject> | |
{ | |
private final String _inputParameter; | |
// Constuctor | |
public LogInTask(String _inputParameter) | |
{ | |
_inputParameter = inputParameter; | |
} | |
protected LoginResponse doInBackground(Void... voids) | |
{ | |
// | |
// Background code | |
// ..... | |
return new ResultObject(); | |
} | |
protected void onPostExecute(ResultObject result) | |
{ | |
// | |
// Code on the main thread | |
// ..... | |
// Send the result to the delegate. | |
} | |
} | |
// | |
// Example usage | |
// | |
ExampleAsyncTask exampleAsyncTask = new ExampleAsyncTask("paramter"); | |
exampleAsyncTask.execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment