Skip to content

Instantly share code, notes, and snippets.

@ducalpha
Created August 14, 2013 05:32
Show Gist options
  • Save ducalpha/6228270 to your computer and use it in GitHub Desktop.
Save ducalpha/6228270 to your computer and use it in GitHub Desktop.
AsyncTask example
/* wrapper of Java thread */
public void onButtonClicked() {
new RxBytesCheck().execute();
}
private class RxBytesCheck extends AsyncTask<Void, Void, Long> {
@Override
protected Long doInBackground(Void... params)
{
return TrafficStats.getTotalRxBytes();
}
@Override
protected void onPostExecute(Long result)
{
TextView mainTextView = (TextView) findViewById(R.id.main_text_view);
mainTextView.setText(result.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment