title: Check if Android handler has callbacks
body: <p>I have some code which sets a timer, but if a user sets the timer while it is in use I need to  remove the runnable which runs the timer and start it again. But when no handler callback runnable exists and this code is called it crashes my application. So I need to check if a handler is running, if so then end it and restart it, but looking through the documentation and other Stackoverflow questions, I cannot see if this is possible.</p>
  
  <p>Here is my code, I have commented around the code which should only be executed if a handler runnable exists:</p>
  
  <pre><code>    submitTimer.setOnClickListener(new View.OnClickListener(){
  
          public void onClick(View v) {
              String s = timer.getText().toString();
              if(!s.equals(""))
              {
  //I NEED TO CHECK A RUNNABLE HANDLER EXISTS AND IF SO THEN RUN THIS CODE, IF NOT IGNORE THIS CODE
              Map.handler.removeCallbacks(Map.getRunnable());
              Map.runnable.run();
  //I NEED TO CHECK A RUNNABLE HANDLER EXISTS AND IF SO THEN RUN THIS CODE, IF NOT IGNORE THIS CODE
              int l = Integer.parseInt(s);
              Map.timerinmins = l;
              timer.setHint("Current Timer is "+Map.timerinmins);
              timer.setText("");
              Toast.makeText(Preferences.this, "Timer is set!", Toast.LENGTH_SHORT).show();
              }
  
              else
              {
  
                  Toast.makeText(Preferences.this, "No value was entered", Toast.LENGTH_SHORT).show();
              }
      }
  
  });
  </code></pre>
  
  <p>Can anyone help me figure out a way of checking the handlers current state?</p>