@@ -24,7 +24,6 @@ namespace CommunityToolkit.Maui.Core.Views;
2424
2525public partial class MediaManager : Java . Lang . Object , IPlayerListener
2626{
27- const string Tag = "MediaManager" ;
2827 const int bufferState = 2 ;
2928 const int readyState = 3 ;
3029 const int endedState = 4 ;
@@ -41,14 +40,6 @@ public partial class MediaManager : Java.Lang.Object, IPlayerListener
4140 MediaItem . Builder ? mediaItem ;
4241 BoundServiceConnection ? connection ;
4342
44- // Store sessionActivityPendingIntent for notification contentIntent fallback (Android 14+)
45- static PendingIntent ? _sessionActivityPendingIntent ;
46-
47- /// <summary>
48- /// Gets the session activity PendingIntent for notification contentIntent fallback (Android 14+ Pixel 7a fix).
49- /// </summary>
50- public static PendingIntent ? SessionActivityPendingIntent => _sessionActivityPendingIntent ;
51-
5243 /// <summary>
5344 /// The platform native counterpart of <see cref="MediaElement"/>.
5445 /// </summary>
@@ -186,35 +177,6 @@ or PlaybackState.StateSkippingToQueueItem
186177 var mediaSession = new MediaSession . Builder ( Platform . AppContext , Player ) ;
187178 mediaSession . SetId ( Convert . ToBase64String ( Guid . NewGuid ( ) . ToByteArray ( ) ) [ ..8 ] ) ;
188179
189- // Set session activity PendingIntent to bring app to foreground when notification body is tapped (Android 14+)
190- // This is the recommended approach for Android 14+ notification body taps
191- // Uses explicit Intent targeting MainActivity with CLEAR_TOP | SINGLE_TOP flags for 100% reliability
192- try
193- {
194- var activity = Microsoft . Maui . ApplicationModel . Platform . CurrentActivity
195- ?? throw new InvalidOperationException ( "CurrentActivity is null - this should never happen" ) ;
196-
197- var sessionIntent = new Intent ( activity , activity . GetType ( ) )
198- . AddFlags ( ActivityFlags . ClearTop | ActivityFlags . SingleTop )
199- . SetAction ( Intent . ActionMain )
200- . AddCategory ( Intent . CategoryLauncher ) ;
201-
202- var sessionActivityPendingIntent = PendingIntent . GetActivity (
203- activity , // ⚠️ CRITICAL: Use the Activity, NOT AppContext
204- 0 ,
205- sessionIntent ,
206- PendingIntentFlags . Immutable | PendingIntentFlags . UpdateCurrent ) ;
207-
208- mediaSession . SetSessionActivity ( sessionActivityPendingIntent ) ;
209-
210- // Store for notification contentIntent fallback (Android 14+ Pixel 7a fix)
211- _sessionActivityPendingIntent = sessionActivityPendingIntent ;
212- }
213- catch ( Exception ex )
214- {
215- Android . Util . Log . Error ( Tag , $ "Failed to set session activity: { ex } ") ;
216- }
217-
218180 session ??= mediaSession . Build ( ) ?? throw new InvalidOperationException ( "Session cannot be null" ) ;
219181 ArgumentNullException . ThrowIfNull ( session . Id ) ;
220182
0 commit comments