Skip to content

Instantly share code, notes, and snippets.

@ptsiogas
Last active September 20, 2015 17:54
Show Gist options
  • Save ptsiogas/a1c26ea0a87d4e2bf4d9 to your computer and use it in GitHub Desktop.
Save ptsiogas/a1c26ea0a87d4e2bf4d9 to your computer and use it in GitHub Desktop.
Run an Async Task (Android)
//Declare variable and execute async
DownloadFilesTask mDonwloadFilesTask;
mDonwloadFilesTask = new DownloadFilesTask();
mDonwloadFilesTask.execute("");
//----------------------------------
public class DownloadFilesTask extends AsyncTask<String, Void, String> {
protected String doInBackground(String... params) {
//do all the heavy staff here but dont you dare messing with the UI!
return "Executed!";
}
@Override
protected void onPostExecute(String result) {
//here you can even change the layout
}
@Override
protected void onPreExecute() {}
@Override
protected void onProgressUpdate(Void... values) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment