After many tries, I decided to ask the question again. In my last question, someone said I should have a look at Jsoup. I wrote some code but it won't work. It's an android app. But it totally crashes. with the error message:
Unfortunately, (appname) has stopped
See the full error message
My code for extracting text from the <div>:
public void ButtonClick(View view) throws IOException {
Document doc = dereference("here is my url");
String text = extractContent(doc);
updateUI(text);
}
private Document dereference(String uri) {
Connection connection = Jsoup.connect(uri);
return connection.get();
}
private String extractContent(Document doc) {
Elements divs = doc.select("div.onlinestatus");
return divs.text();
}
private void updateUI(String text) {
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText(text);
}
the input from the url:
<html><!-- [...] --><body>
<div class='onlinestatus'>Server ist online! <br /></div>
</body></html>
Can someone spot the mistake?
Edit: when I perform all these operations in a separate thread, I get a different error. Error log and code can be found here.