I have to notify an action that occurs within the site, I have the following code that. Appears in a texview and wanted to notify enves of sending the name to textview. TextView txv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txv = (TextView) findViewById(R.id.hello);
new RequestTask().execute("http://sites.ecomp.uefs.br/perta/");
}
class RequestTask extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... uri) {
String text = null;
try {
// pega o codigo html de um site
Document doc = Jsoup.connect(uri[0]).get();
// pega um elemento do codigo
Elements newsHeadlines = doc.select("#sites-header-title");
// pega o texto dentro do codigo
text = newsHeadlines.text();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return text;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if(result != null){
txv.setText(result);
}else{
txv.setText("FALHA!");
}
}
}