-
Notifications
You must be signed in to change notification settings - Fork 471
Fix clicking on notification does not restore activity #2979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix clicking on notification does not restore activity #2979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes notification click behavior in the MediaControlsService for Android by adding a content intent that properly restores the main app activity when the user taps the foreground service notification.
Key changes:
- Added
CreateActivityPendingIntent()helper method to construct the appropriate PendingIntent - Integrated the PendingIntent into the notification builder via
SetContentIntent()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Description of Change
This pull request improves the behavior of the foreground service notification in the
MediaControlsServicefor Android by ensuring that tapping the notification brings the user back to the main app activity. The changes introduce a helper method to create the appropriatePendingIntentand attach it to the notification.Enhancement to notification interaction:
MediaControlsServicenow includes a content intent, so tapping the notification will launch (or bring to front) the main app activity. This is achieved by creating aPendingIntentusing the newCreateActivityPendingIntent()method and setting it withSetContentIntenton the notification builder.Internal code improvements:
CreateActivityPendingIntent()method that safely constructs aPendingIntentto launch the main activity, handling potential null references and setting intent flags to ensure correct activity behavior.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Fixes a long standing issue where clicking on notification after leaving app does not restore app. This fixes that issue and restores expected default android behavior.