Here is an Example:-
On your oncreate method do this
txtMessage = (TextView) findViewById(R.id.txt_push_message);
new task().execute();
class task extends AsyncTask<String, String,String>{
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
txtMessage.setText("Hi there");
}
@Override
protected String doInBackground(String... params) {
//Do something related to get the data and return that
//Return the proper value
return null;
}
}
2
solved How to use Android network access, threads and handlers [closed]