title: how to prevent to start multiple startId In Android
body: <p>I am using the following code and when I click on button I get multiple <code>startId</code> creations in service. Can somebody tell me how to prevent starting multiple <code>startId</code> In Android?</p>
  
  <pre><code>@Override
  public int onStartCommand(Intent intent, int flags, final int startId) {
  handler.postDelayed(new Runnable() {
  public void run() {
  System.out.println(startId+ " == startId");
  handler.postDelayed(this, 8000);
  }
  }, 8000); 
  
  return super.onStartCommand(intent, flags, startId);}
  </code></pre>
  
  <p>This is the output that I'm getting:</p>
  
  <pre><code>03-09 02:39:14.128 18298-18298/com.simple.project I/System.out: 1 == startId
  
  03-09 02:39:14.268 18298-18298/com.simple.project I/System.out: 2 == startId
  
  03-09 02:39:14.449 18298-18298/com.simple.project I/System.out: 3 == startId
  
  03-09 02:39:14.719 18298-18298/com.simple.project I/System.out: 4 == startId
  
  03-09 02:39:15.059 18298-18298/com.simple.project I/System.out: 5 == startId
  
  03-09 02:39:15.219 18298-18298/com.simple.project I/System.out: 6 == startId
  
  03-09 02:39:15.409 18298-18298/com.simple.project I/System.out: 7 == startId
  
  03-09 02:39:15.580 18298-18298/com.simple.project I/System.out: 8 == startId
  
  03-09 02:39:15.740 18298-18298/com.simple.project I/System.out: 9 == startId
  
  03-09 02:39:15.900 18298-18298/com.simple.project I/System.out: 10 == startId
  </code></pre>