开发者

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!


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">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜