Android 14+ Notification Body Tap Not Working on MediaStyle Notifications #2975
justcoding121
started this conversation in
New Feature Discussions
Replies: 1 comment 1 reply
-
|
Thank you for the suggestion. I agree this needs to be fixed. I will work on creating a PR. But can you open a bug report and add the info above? @justcoding121 That would be very helpful for me. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
On Android 14+ (API 34+), MediaStyle notification body taps do not open the app when using
CommunityToolkit.Maui.MediaElement7.0.0. The notification body tap triggers the defaultMediaSession.Callback.OnPlay()method (which just plays/pauses) instead of opening the app, even whenSessionActivityis set.Environment
CommunityToolkit.Maui.MediaElementversion 7.0.0SessionActivity)Problem Description
Expected Behavior
When a user taps the notification body (title/artwork area) of a MediaStyle notification, the app should open and navigate to the appropriate screen.
Actual Behavior
On Android 14+ (especially Pixel devices), tapping the notification body:
MediaSession.Callback.OnPlay()which just plays/pauses the mediaContentIntentandSessionActivityare ignored by the systemRoot Cause
According to Android's official documentation:
The Problem:
androidx.media3.session.MediaSession)MediaSessioncallback is set during session creation viaMediaSession.Builder.setCallback()MediaSessioninternally inMediaManager.android.cswithout exposing a way to set a custom callbackMediaSessiondoes not allow changing the callback after creation (it's immutable)OnPlay()to launch the app instead of just playing/pausingCode Reference
In
MediaManager.android.cs(line 174-177):Workaround Attempts
We've tried several approaches, all of which fail on Android 14+ Pixel devices:
SessionActivity- Works on Android 8-13 and some Android 14+ OEMs, but ignored on Pixel/stock Android 14+MediaSessiondoesn't exposesetCallback()method after creationContentIntent, but Android 14+ still routes body taps to the callback'sOnPlay()insteadProposed Solutions
Option 1: Expose MediaSession Callback Configuration (Recommended)
Allow developers to provide a custom
MediaSession.Callbackwhen creating the MediaSession:Option 2: Provide MediaSession Builder Extension Point
Allow developers to customize the
MediaSession.Builderbefore it's built:Option 3: Handle OnPlay() in Default Callback
Modify the default callback to check for a custom intent/action and launch the app if configured:
Impact
This is a critical UX issue for media apps that need to:
Affected Use Cases:
Comparison with Media2/ExoPlayer 2
The older Media2 implementation (used in MediaElement 6.x and other libraries) allowed setting the callback after session creation and had a
MediaDescriptionAdapterpattern that worked around this limitation. Media3's stricter architecture makes this impossible without framework support.Additional Context
Request
Please add a way for developers to customize the
MediaSession.Callbackin MediaElement 7.0.0+ to properly handle Android 14+ notification body taps. This is essential for apps that need to open the app (rather than just play/pause) when users interact with media notifications.Related Issues: (if any exist in the repository)
Labels:
android,mediaelement,android14,notification,bug,enhancementBeta Was this translation helpful? Give feedback.
All reactions