Skip to content

Instantly share code, notes, and snippets.

@wakim
Last active February 18, 2016 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wakim/c139b68eeeeae0b36374 to your computer and use it in GitHub Desktop.
Save wakim/c139b68eeeeae0b36374 to your computer and use it in GitHub Desktop.
public class HeavyWorkTask extends AsyncTask<String, Void, String> {
TextView mStatusTextView;
public HeavyWorkTask(TextView statusTextView) {
mStatusTextView = statusTextView;
}
@Override
protected String doInBackground(String... urls) {
return doHeavyWork(urls[0]);
}
@Override
protected void onPostExecute(String result) {
mStatusTextView.setText(result);
}
String doHeavyWork(String url) {
// realiza algum trabalho e retorna o resultado do processamento
return ...;
}
}
new HeavyWorkTask(mStatusTextView).execute(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment