Reputation: 25
What's wrong? When I'm clicking the BTN it's stopping (unexpected). This is the part of code which works wrong, the lib I use is Jsoap. Help me pls
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
doc = Jsoup.connect("http://hitage.ru").get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Elements nodes = doc.getElementsByAttributeValueStarting("class", "page node");
}
});
Upvotes: 0
Views: 157
Reputation: 15766
You cannot make network calls on the UI thread. You need to use an AsyncTask or something similar. Also, make sure you have
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml
.
Upvotes: 2