Question

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!

Was it helpful?

Solution

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">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top