title: Android: Don't exit after an exception
body: <p>How can i make that my app dosen't exit after an UnknownHostException?</p>
  
  <p>My code actually:</p>
  
  <pre><code>    public String getXmlFromUrl(String url, String Username, String Passwd){
      String xml = null;
      try{
          DefaultHttpClient httpClient = new DefaultHttpClient();
          httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
  
          NTCredentials creds = new NTCredentials(Username, Passwd, "AndroidApp", "****");
  
          httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
          HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 1000);
  
          HttpGet httpGet = new HttpGet(url);
          httpGet.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
  
          HttpResponse httpResponse = httpClient.execute(httpGet);
          HttpEntity httpEntity = httpResponse.getEntity();
          xml = EntityUtils.toString(httpEntity);
  
      } catch (UnknownHostException e){
          e.printStackTrace();
          Log.e("HTTPClient", "Unknown Host");
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (ClientProtocolException e) {
          e.printStackTrace();
      } catch (ConnectTimeoutException e) {
          e.printStackTrace();
          Log.e("HTTPClient", "Connection Timeout");
      } catch (NoHttpResponseException e) {
          e.printStackTrace();
          Log.e("HTTPClient", "No Response");
      } catch (ParseException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();            
      }
  
      return xml;
  }
  </code></pre>
  
  <p>To get the exception is to click on a login button then the app load an xml file over http on the phone.
  In place of the exception comes an dialog for User that the hostname don't exists.</p>
  
  <p>Same for other exceptions...</p>
  
  <p><strong>Update:
  Ok i've found a solution.
  I had added a NullPointerException when i'm switching between the Fragments</strong></p>