Eric
Eric

Reputation: 4375

Android JSoup Connection Issues

Using the guide on JSoup's website I wrote the following code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
        Document doc = Jsoup.connect("http://google.com").get();
        Elements links = doc.getElementsByTag("a");
        for(Element ele : links){
            Log.i("Menu", ele.text());
        }
    } catch (IOException e) {

    }
    setContentView(R.layout.main);
}

I added the internet permission in my manifest file but it keeps throwing an IOException!

Upvotes: 0

Views: 1008

Answers (1)

Adam Storm
Adam Storm

Reputation: 724

I tested your code and it should work fine... I would imagine your permission was put in the wrong spot. It goes BEFORE your application definition in your manifest:

here are the first few lines of my manifest that runs your code:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">

Upvotes: 2

Related Questions