문제

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!

도움이 되었습니까?

해결책

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">
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top