Last active
January 11, 2020 13:33
-
-
Save shikto1/90b020aac05bdc611e1219d968e42104 to your computer and use it in GitHub Desktop.
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
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