title: How to listen to "ACTION_DOWN" (key pressed) event in Android onMediaButtonEvent, in order to measure the time?
body: <p>I try to get the time <code>System.currentTimeMillis()</code>, than the user presses the media button. But the callback is executed at the time when the media button goes up again <code>action == KeyEvent.ACTION_UP</code>. </p>
  
  <blockquote>
    <p>I don't want to use a BroadcastReceiver for my solution.</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>    MediaSession audioSession = new MediaSession(getApplicationContext(), "TAG");
      audioSession.setCallback(new MediaSession.Callback() {
  
          @Override
          public boolean onMediaButtonEvent(final Intent mediaButtonIntent) {
              String intentAction = mediaButtonIntent.getAction();
  
              if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction))
              {
                  KeyEvent event = (KeyEvent)mediaButtonIntent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
                  if (event != null)
                  {
                      int action = event.getAction();
                      if (action == KeyEvent.ACTION_DOWN) {
                          long stopTimeOfGame_millis = System.currentTimeMillis();
                          UtilsRG.info("time stopped: " +stopTimeOfGame_millis);
  
                      }
                      if (action == KeyEvent.ACTION_UP) {
                           long test = System.currentTimeMillis();
                           UtilsRG.info("time stopped up: " +test);
  
                      }
                  }
  
              }
              return super.onMediaButtonEvent(mediaButtonIntent);
          }
  
  
  
      });
  
      PlaybackState state = new PlaybackState.Builder()
              .setActions(PlaybackState.ACTION_PLAY_PAUSE)
              .setState(PlaybackState.STATE_PLAYING, 0, 0, 0)
              .build();
      audioSession.setPlaybackState(state);
  
      audioSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
  
      audioSession.setActive(true); 
  </code></pre>
  
  <p>The log output: </p>
  
  <blockquote>
    <p>time stopped down: 1473420286380<br>
        time stopped up:   1473420286383</p>
  </blockquote>
  
  <p>In my opinion the difference is too small between these values.</p>