I have an application, it will parse data from Youtube's playlist, the data is formatted like XML. I am using SAXParser to do this. But having a issue when using InputStream with SAXParser.
SAXParser saxParser = saxFactory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
xmlReader.setContentHandler(this);
URLConnection urlConnection = new URL(pURL).openConnection();
urlConnection.setConnectTimeout(10000);
InputStream inputStream = urlConnection.getInputStream();/*always die here*/
xmlReader.parse(new InputSource(inputStream));
The class that contains code is extending DefaultHandler.
With this code, if I run with class DataASyn extends AsyncTask<Void, Void, Void>
it is ok and run well, but when I run without DataAsyn, it is always died as I described above. I do not know why ????
I also debug when on background, and recognize that at InputStream inputStream = urlConnection.getInputStream();
program will pause some seconds before continuing run, maybe it was waiting for data ?!?
I hope all information above, anyone will know what has happened and give me any ideas about it.
Thanks, Ryan