Android app crash on 3G slow connection but works fine over wifi
<p>I have a small android app that basically perform a http call to retrieve some web page info and parse it locally for display purpose.</p>

<p>It works fine on wifi. However, the app crashes randomly when on 3G (not all the time, but frequently enough) after submitting the http query. Often I was able to just restart the app, try to perform the same task and it will work as it's intended to. I am kinda stuck trying to debug this problem. Is it caused by slow internet connection? packet drop? What kind of checking code I can put in there to prevent this from happening?</p>

<p>Some example code:</p>

<pre><code>    HttpClient client = new DefaultHttpClient();
    HashMap&lt;String, String[]&gt; hmSearchResults = null;       
    HttpGet getMethod = new HttpGet(url);

    try {

        ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();

        String resultPage = client.execute(getMethod, responseHandler);

        // I am think the error is here if resultPage == null due to 
        // whatever reason, is there any check I can put around 
        // client.execute?
        hmSearchResults = ParseHtml.getSearchResultText(resultPage, numRequestResults);

    } catch (Throwable t) {     
        Utility.showToast(this,"Request failed: " + t.toString());
    }
</code></pre>
