title: Stopping service doesn't stop long polling in it
body: <p>So I have this code in my service.</p>
  
  <pre><code>public void longPolling(String url) {
      HttpURLConnection connection = null;
      BufferedReader rd = null;
      StringBuilder sb = null;
      String line = null;
  
      URL serverAddress = null;
  
      String lastModify = null;
      String etag = null;
  
      while (true) {
  
          try {
              serverAddress = new URL(url);
              // set up out communications stuff
              connection = null;
  
              // Set up the initial connection
              connection = (HttpURLConnection) serverAddress.openConnection();
              connection.setRequestMethod("GET");
              // connection.setDoOutput(true);
              connection.setReadTimeout(60000);
  
              if (lastModify != null) {
                  connection.setRequestProperty("If-Modified-Since",
                          lastModify);
              }
  
              if (etag != null) {
                  connection.setRequestProperty("If-None-Match", etag);
              }
  
              connection.connect();
              // read the result from the server
  
              rd = new BufferedReader(new InputStreamReader(
                      connection.getInputStream()));
  
              sb = new StringBuilder();
              while ((line = rd.readLine()) != null) {
                  sb.append(line + '\n');
              }
  
              lastModify = connection.getHeaderField("Last-Modified");
              etag = connection.getHeaderField("Etag");
              String response = java.net.URLDecoder.decode(sb.toString(),
                      "UTF-8");
              sendResults(response); //sends broadcast to activities.
  
          } catch (MalformedURLException e) {
              log.debug(e);
              e.printStackTrace();
          } catch (ProtocolException e) {
              e.printStackTrace();
              log.debug(e);
          } catch (IOException e) {
              e.printStackTrace();
              log.debug(e);
          } catch (Exception e) {
              e.printStackTrace();
              log.debug(e);
          } finally { // close the connection, set all objects to null
              connection.disconnect();
              rd = null;
              sb = null;
              connection = null;
          }
  
      }
  }
  </code></pre>
  
  <p>It works fine. But when user logs out off the app, Service should be stopped. But this polling doesn't stop. It kept on running even if the service is stopped.</p>