Skip to content

Instantly share code, notes, and snippets.

@shikto1
Last active January 11, 2020 13:33
Show Gist options
  • Save shikto1/90b020aac05bdc611e1219d968e42104 to your computer and use it in GitHub Desktop.
Save shikto1/90b020aac05bdc611e1219d968e42104 to your computer and use it in GitHub Desktop.
public class AsyncActivity extends Activity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_async);
textView = (TextView) findViewById(R.id.textView);
new BackgroundTask().execute();
}
private class BackgroundTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
// Do background work. Code omitted.
return "some string";
}
@Override
protected void onPostExecute(String result) {
textView.setText(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment