有什么运气让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()));