Search code examples
javaandroidjsoup

How to get text from html to TextView with Jsoup, no buttons?


so I wrote this but Android Studio says "class news is never used" what am I doing wrong?

public class news extends AsyncTask<Void,Void,Void> {
    String words;
    @Override
    protected Void doInBackground(Void... params) {
      try{
         Document doc = Jsoup.connect("myurl").get();
         Elements ele = doc.select("div#home-right");
         words = ele.text();
      }catch(Exception e){e.printStackTrace();}
      return null;
    }   
    TextView.setText(words);
}

Solution

  • In your activity class, put this code:

    news n = new news();
    n.execute();