Skip to content Skip to sidebar Skip to footer

Adding A Custom User Action To The Android Media Session

I'm trying to add a custom user action to my media session so that it shows up on the android auto action card, but I can't seem to get it to work. I've looked around, but didn't f

Solution 1:

In order to add a custom action and given a PlayBackStateCompat.Builder you can add a custom action as follows:

mStateBuilder.addCustomAction(
            new PlaybackStateCompat.CustomAction.Builder(
                    CUSTOM_ACTION_REPLAY,
                    getString(R.string.custom_action_replay),
                    R.drawable.ic_replay).build()
    );

Then you must add the code to handle the custom action as you already did. The code above should work, and correctly display the actions on Android Auto, i use this to display the custom action. Hope this helps even if i am little late


Post a Comment for "Adding A Custom User Action To The Android Media Session"