Quantcast
Channel: Using HttpUrlconnection in Rss Reader causes Android to hang - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Amanda for Using HttpUrlconnection in Rss Reader causes Android to hang

$
0
0

What you need to do is put it into a string I called it results. I have attached my code for the doInBackground. By adding it to a string it has a place to store the feed. And it works for the rss reader.

public String doInBackground(String... urls){        String result = "";        try{            URL url = new URL(urls[0]);            HttpURLConnection conn = (HttpURLConnection) url.openConnection();            InputStream in = conn.getInputStream();            BufferedReader reader = new BufferedReader(new InputStreamReader(in));            String line = "";            while((line = reader.readLine()) != null){                result = result + line;            }            conn.disconnect();        }        catch(Exception e){            Log.e("ERROR Fetching ", e.toString());        }        return result;    }

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>