media icon indicating copy to clipboard operation
media copied to clipboard

MediaMetadataCompat title item, how avoid clickable or browsing - Android Auto

Open billyjoker opened this issue 1 year ago • 5 comments

Hi I am facing an issue using MediaMetadataCompat for Android Auto extension apps. I am trying to create a head title before the items, but that title has the click feautre active to browse or play and I do not the way to disable it, so I do not want it as clickable, only just as a header

            val headerMediaItem = MediaMetadataCompat.Builder().apply {
                putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, "HEADER_ID")
                putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Header items title")
                flag = MediaBrowserCompat.MediaItem.FLAG_PLAYABLE // FLAG_BROWSABLE both are clickables
            }.build()

I guess it must to be a way to create "dumb" items, not playable, not browsable, but I did not figured out.

Thanks in advance

billyjoker avatar Sep 11 '24 13:09 billyjoker

To clarify, when setting the flags for the MediaBrowserCompat.MediaItem, the flag is indeed an integer, and by passing 0, you're explicitly stating that there should be no actions (neither FLAG_PLAYABLE nor FLAG_BROWSABLE):

val headerMediaItem = MediaMetadataCompat.Builder().apply {
    putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, "HEADER_ID")
    putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Header items title")
    flag = 0 // no flags, making it non-clickable
}.build()

rohitjoins avatar Sep 12 '24 01:09 rohitjoins

falg = 0 has no effect, it is clickable anyway

It seems that migrating to media3 there is an attribute to make it, but migrating now for me it is not a choice

billyjoker avatar Sep 12 '24 15:09 billyjoker

Apologies, my mistake. I'll hand this over to @marcbaechinger, who is an expert in this area.

rohitjoins avatar Sep 16 '24 08:09 rohitjoins

Hi @marcbaechinger any ideas on this one?

billyjoker avatar Sep 24 '24 09:09 billyjoker

@marcbaechinger any thoughts on this one ?

billyjoker avatar Sep 30 '24 08:09 billyjoker

Hi I finally solved it adding a extra with a flag from MediaConstants called DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE. So adding it to a group of elements with a title, it is placed as a header with the proper stylement.

billyjoker avatar Oct 30 '24 09:10 billyjoker