I have a strange problem. I get the following error, which causes a forced close:
org.apache.harmony.xml.ExpatParser $ ParseException: row 1 column 0: element is missing from org.apache.harmony.xml.ExpatParser.parseFragment (ExpatParser.java:508) at org.apache.harmony.xml.ExpatParser. parseDocument (ExpatParser.java:467) at org.apache.harmony.xml.ExpatReader.parse (ExpatReader.java:329) at org.apache.harmony.xml.ExpatReader.parse (ExpatReader.java:286)
After clicking the "Force Close" button, the activity will be recreated, and the parsing will end without a hitch. I use the following code snippet inside doInBackground for AsyncTask:
URL serverAddress = new URL(url[0]);
HttpURLConnection connection = (HttpURLConnection) serverAddress.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setReadTimeout(10000);
connection.connect();
InputStream stream = connection.getInputStream();
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.parse(new InputSource(stream));
, ? BufferedInputStream ? .: (
.
: , HttpURLConnection.getResponseCode() -1 , InputStream, , .