Fix clicking on notification does not restore activity #2979
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.