使用类URL的函数openStream进行IOException

时间:2013-06-11 09:37:52

标签: android url ioexception

我有这个函数的IOException:

protected Boolean doInBackground(Object... params)
    {
        boolean result = false;
        String path = (String) params[0];
        table = (TableLayout) params[1];

        XmlPullParser topScores = null;

        Log.i("topTen","Entro en doInBsck "+path);

        try {
            Vector<NameValuePair> vars = new Vector<NameValuePair>();
            vars.add(new BasicNameValuePair("figurename", "completo"));
            String ind=path+URLEncodedUtils.format(vars, null);
            URL xmlUrl=new URL(ind);
            topScores = XmlPullParserFactory.newInstance().newPullParser();
            topScores.setInput(xmlUrl.openStream(),null);

        } catch (XmlPullParserException e) {
            Log.i("topTen","Excepcion XML" );
            Log.i("topTen",e.getLocalizedMessage());
            topScores = null;

        } catch(MalformedURLException e) {
            Log.i("topTen","Excepcion URL" );
            Log.i("topTen",e.getMessage());
            topScores = null;
        }

        catch (IOException e) {
            Log.i("topTen","Excepcion IO");
            Log.i("topTen",e.getMessage());
            topScores = null;

        } 

        if(topScores != null) {
            try {
                processScores(topScores);
            } catch (XmlPullParserException e) {
                Log.e("DEBUG_TAG", "doInBackground() inside TopScoresDownloader : Pull Parser failure", e);
            } catch (IOException e) {
                Log.e("DEBUG_TAG", "doInBackground() inside  TopScoresDonwloader : IO Exception parsing XML",e);
            }
        }
        return result;
    }

我在清单中有这些权限:

<user-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_ STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

并在日志中我读到了这条消息:

<Unable to resolve host "ptha.ii.uam.es": No address associated with hostname>    

我尝试在手机的浏览器中看到网址,然后连接下摆!

我不知道是什么问题!

1 个答案:

答案 0 :(得分:0)

这是一个错字!变化

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

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