Skip to content

Instantly share code, notes, and snippets.

@rsaunders100
Created September 7, 2011 15:54
Show Gist options
  • Save rsaunders100/1200952 to your computer and use it in GitHub Desktop.
Save rsaunders100/1200952 to your computer and use it in GitHub Desktop.
(Android) The basic structure of Android's Async task.
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