URLonnection和Android的setReadTimeout

时间:2011-04-26 17:46:11

标签: android timeout httpurlconnection urlconnection

有什么运气让setReadTimeout在Android上工作吗?我尝试了不同的解决方案,似乎没有工作

    URLConnection connection;
    XMLReader xr = sp.getXMLReader();

    /** Send URL to parse XML Tags */
    URL sourceUrl = new URL(urlString);
    connection = (URLConnection)sourceUrl.openConnection();
    connection.setReadTimeout(5000);

    connection.connect();


    /** Create handler to handle XML Tags ( extends DefaultHandler ) */
    MyXMLHandler myXMLHandler = new MyXMLHandler();
    xr.setContentHandler(myXMLHandler);
    xr.parse(new InputSource(connection.getInputStream()));

0 个答案:

没有答案