I managed to get the headset intents code from this thread to work on my Android 5 phone, now I have an Android 8 phone I don't get any events from the headset button, the app runs and shows starter service running on the screen but it never gets the media button actions.