1

I am implementing Android Auto into an existing music application. I would like to add the action button to the main action card for the audio player in auto to open the navigation drawer but I can't seem to figure out how to get there.

Any help would be appreciated.

Example of main action card can be viewed here and the button mentioned would be the one on the far left.

  • 1
    Please post the code related to the specific problem here. Outbound links tend to become unavailable. – rupps May 05 '17 at 23:28

1 Answers1

0

Custom actions should be adding through PlaybackState and addCustomAction()

https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.Builder.html#addCustomAction(java.lang.String, java.lang.String, int)

Important point, there is flags to indicate to auto if main page controller should keep empty space when "next" and "previous" are not enable.

private static final String SLOT_RESERVATION_SKIP_TO_NEXT =
        "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_NEXT";
private static final String SLOT_RESERVATION_SKIP_TO_PREV =
        "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_PREVIOUS";

that you add at your MediaSessionCompat with setExtras() method. With flags, custom actions are added in a second screen that you acceed in swiping main Auto audio meta screen. With no flags, custom actions are added next to Play/Pause button.

smora
  • 717
  • 5
  • 18