I find that when the network connection is slow, my Android application is force-closed
<p>I find that when the network connection is slow, my Android application is force-closed.</p>

<p>I am using following code to check the internet connection</p>

<pre><code> public  boolean isNetworkAvailable(Context context) 
        {
            try
            {           
                ConnectivityManager cm =
                    (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
                 NetworkInfo netInfo = cm.getActiveNetworkInfo();       
                Log.v("Test--",""+netInfo.isAvailable());
                if ( netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()&amp;&amp; netInfo.isAvailable()) {
                    return true;
                }
                return false;
            }
            catch (Exception ex)
         {    
                return false;
            }

        }
</code></pre>
