Created
November 10, 2013 20:23
-
-
Save JenkinsDev/7403437 to your computer and use it in GitHub Desktop.
Basic AsyncTask layout that I point people to when they are confused.
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
public class MyAsyncTaskName extends AsyncTask<String, Integer, String> { | |
// String: The first string is the parameter, this is what is passed to doInBackground() | |
// Integer: The first, and only, Integer type is used for progress updates, this is what is passed to onProgressUpdate() | |
// String: The second String is for what is returned by doInBackground() and what is passed to onPostExecution(); | |
@Override | |
protected void onPreExecute() { | |
// Handles what happens before the AsyncTask fully executes. | |
// Here you can do things like add a progress bar, loading animation, etc. | |
} | |
@Override | |
protected String doInBackground(String... urls) { | |
// Handles the meat of the AsyncTask. | |
} | |
@Override | |
protected void onProgressUpdate(Integer... progress) { | |
// Handles progress updating, use this to update a progress bar, etc. | |
} | |
@Override | |
protected void onPostExecute(String result) { | |
// Handles what happens after the AsyncTask execution ends. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment