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);
}
You have to call your "news" class. So in activity in onCreate method call new news(this).execute(); Remeber to make class with Uppercase letter.
In your activity class, put this code:
news n = new news();
n.execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.