Created
August 14, 2013 05:32
-
-
Save ducalpha/6228270 to your computer and use it in GitHub Desktop.
AsyncTask example
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
/* 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