title: Android unknownhostexception
body: <p>I have the following code that if not connected to the internet hits the catch but crashes the app with the error in the subject.  Is there a graceful way to detect the connection being up or just ignore this?</p>
  
  <pre><code> try {
  
          GeoPoint center = myMapView.getMapCenter();
          double minLat = (double) (center.getLatitudeE6() - (myMapView
                  .getLatitudeSpan() / 2)) / 1E6;
          double maxLat = (double) (center.getLatitudeE6() + (myMapView
                  .getLatitudeSpan() / 2)) / 1E6;
          double minLng = (double) (center.getLongitudeE6() - (myMapView
                  .getLongitudeSpan() / 2)) / 1E6;
          double maxLng = (double) (center.getLongitudeE6() + (myMapView
                  .getLongitudeSpan() / 2)) / 1E6;
  
          /* Create a URL we want to load some xml-data from. */
          URL url = new URL(
                  "http://www.test.com/feed.asp?maxlat="
                          + Double.toString(maxLat) + "&amp;maxlon="
                          + Double.toString(maxLng) + "&amp;minlat="
                          + Double.toString(minLat) + "&amp;minlon="
                          + Double.toString(minLng));
  
          /* Get a SAXParser from the SAXPArserFactory. */
          SAXParserFactory spf = SAXParserFactory.newInstance();
          SAXParser sp = spf.newSAXParser();
  
          /* Get the XMLReader of the SAXParser we created. */
          XMLReader xr = sp.getXMLReader();
          /* Create a new ContentHandler and apply it to the XML-Reader */
          XMLHandler myXMLHandler = new XMLHandler();
          xr.setContentHandler(myXMLHandler);
  
          /* Parse the xml-data from our URL. */
          xr.parse(new InputSource(url.openStream()));
          /* Parsing has finished. */
  
          /* Our ExampleHandler now provides the parsed data to us. */
          /*
           * ParsedExampleDataSet parsedExampleDataSet =
           * myExampleHandler.getParsedData();
           */
          ArrayList&lt;Ship&gt; shipArray = myXMLHandler.getShipArray();
          ArrayList&lt;pfOverlayItem&gt; overArray = myXMLHandler.getOverlayArray();
          mainOverlayArray = overArray;
          pfOverlayItem tempOver = null;
  
          Drawable marker = null;
          for (int i = 0; i &lt; mainOverlayArray.size(); i++) {
              tempOver = mainOverlayArray.get(i);
              // tempOver.setMarker(getIcon(tempOver.getshipTypeInt()));
              tempOver.setMarker(getPlaneIcon(tempOver.getcourse()));
          }
  
          sites = new SitesOverlay();
  
      } catch (Exception e) {
          /* Display any Error to the GUI. */
          Log.e("Error", "Problem processing XML", e);
      }
  </code></pre>