City Name Fetching Via GetLocality
<p>I am developing an android application in which i have to fetch the current city name from server. I have achieved this in my following code. the problem is when i try to fetch the current city name and if internet connection slow at that time application is being force closed.  can anyone help me how to Prevent my application being force closed.i just want to toast a simple message like "Slow internet connection". help me to get it.</p>

<pre><code>public String getCity() {
    String city = "";
     try
        {
         Geocoder geo=new Geocoder(mContext, Locale.getDefault());
         Log.i("TAG","latitude"+ latitude+"\n logitude"+longitude);
            List&lt;Address&gt; addresses=geo.getFromLocation(latitude, longitude, maxResults);
               if (addresses.size() &gt; 0) 
               {
                   Log.i("TAG",""+addresses.size()+"-"+addresses.get(0).getLocality());
                   city=addresses.get(0).getLocality();
               }

        }// end of try
        catch(IOException e)
        {
            city="error";
        }
    return city;
}
</code></pre>
