MediaSession is only supported for interacting with Audio and Video players not MediaRecorder, and onMediaButtonEvent callback will be triggered only when the MediaSession is registered and your app should have audio focus granted.
It seems you are trying control the audio recording with your bluetooth headset buttons, you should go with your second approch i.e generic BroadcastReceiver.
Documentation Link : https://developer.android.com/media/legacy/mediasession