Android HTTP request sometimes has no response, until opening the page on a computer
<p>I'm having a very odd issue with getting data from a PHP script in Android. The below example seams to be what everyone suggests to use to get the data. And it works.. for a while. If you run it a couple of times it gets the scores perfectly. But if you wait an hour or two and then try again it will fail over and over again. Nothing actually "fails" though, I do have proper try catch around this and it runs in a Async task, it just returns nothing in the string. This will happen a hundred times, until I open the script on my computer. Then the script shows me the data and the very next time I open in on the phone, it works. Until a few hours later...</p>

<p>I have scoured the internet for the last week, trying ever different example of getting data from the page and they all do the same thing. I even though maybe it was the web-server we are on, so I moved to a new one, same issue.</p>

<p>If you need anymore details let me know. I can give you the PHP script if you think that will help. Although it happens with 5 different scripts that I have.</p>

<pre><code>        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        InputStream is = httpEntity.getContent();

        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();
        Log(json);
</code></pre>
