title: How can I update the title of a menu item in the toolbar dynamically from a service
body: <p>I have a service with a static variable that holds the amount of time elapsed from when it is attached to an activity</p>
  
  <pre><code>public class TimerService extends Service {
  private static final String TAG = "TimerService";
  Handler handler;
  int Seconds, Minutes, MilliSeconds;
  long MillisecondTime, StartTime, TimeBuff, UpdateTime = 0L;
  static String timerTime = "";
  
  private final IBinder iBinder = new MyBinder();
  
  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
      return iBinder;
  }
  
  public void updateTimerTime() {
      handler = new Handler();
  
      Runnable runnable = new Runnable() {
  
          public void run() {
              MillisecondTime = SystemClock.uptimeMillis() - StartTime;
              UpdateTime = TimeBuff + MillisecondTime;
              Seconds = (int) (UpdateTime / 1000);
              Minutes = Seconds / 60;
              Seconds = Seconds % 60;
              MilliSeconds = (int) (UpdateTime % 1000);
              timerTime = "" + Minutes + ":"
                      + String.format("%02d", Seconds) + ":"
                      + String.format("%03d", MilliSeconds);
              handler.postDelayed(this, 0);
              Log.d(TAG, "run: time" + timerTime);
  
          }
  
      };
  
      StartTime = SystemClock.uptimeMillis();
      handler.postDelayed(runnable, 0);
  }
  
  public class MyBinder extends Binder {
      TimerService getService() {
          return TimerService.this;
      }
  }
  }
  </code></pre>
  
  <p>I then want to update the title of the menu item on the toolbar by doing something like this</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
  
      getMenuInflater().inflate(R.menu.menu_main, menu);
  
      Intent intent = new Intent(this, TimerService.class);
      bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
  
      timerService.updateTimerTime();
      final MenuItem timer = menu.findItem(R.id.timer);
      timer.setTitle(TimerService.timerTime);
  
      return super.onCreateOptionsMenu(menu);
  }
  </code></pre>
  
  <p>Obviously it wont work as onCreateOptionsMenu is only called once and it will just set the text to whatever the value of TimerService.timerTime is when the menu is inflated, any help appreciated.</p>