diff --git a/audio_service/CHANGELOG.md b/audio_service/CHANGELOG.md index 658f8fcb..47538694 100644 --- a/audio_service/CHANGELOG.md +++ b/audio_service/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.18.19 + +* Fix onNewIntentListener always returns true (@relaxedSoul) + It prevents other plugins to handle new intents from the OS while the app is running. + ## 0.18.18 * Fix setPlaybackState entitlement issue on iOS. diff --git a/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioServicePlugin.java b/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioServicePlugin.java index b776a840..7929b917 100644 --- a/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioServicePlugin.java +++ b/audio_service/android/src/main/java/com/ryanheise/audioservice/AudioServicePlugin.java @@ -327,7 +327,7 @@ public void onAttachedToActivity(ActivityPluginBinding binding) { // We do this to avoid using the old intent. activity.setIntent(new Intent(Intent.ACTION_MAIN)); } - sendNotificationClicked(); + handleIntent(activity.getIntent()); } @Override @@ -393,17 +393,17 @@ private void disconnect() { private void registerOnNewIntentListener() { activityPluginBinding.addOnNewIntentListener(newIntentListener = (intent) -> { clientInterface.activity.setIntent(intent); - sendNotificationClicked(); - return true; + return handleIntent(intent); }); } - private void sendNotificationClicked() { - Activity activity = clientInterface.activity; - if (audioHandlerInterface != null && activity.getIntent().getAction() != null) { - boolean clicked = activity.getIntent().getAction().equals(AudioService.NOTIFICATION_CLICK_ACTION); - audioHandlerInterface.invokeMethod("onNotificationClicked", mapOf("clicked", clicked)); + private boolean handleIntent(Intent intent) { + if (audioHandlerInterface != null && intent.getAction() != null) { + boolean handled = intent.getAction().equals(AudioService.NOTIFICATION_CLICK_ACTION); + audioHandlerInterface.invokeMethod("onNotificationClicked", mapOf("clicked", handled)); + return handled; } + return false; } private static class ClientInterface implements MethodCallHandler { diff --git a/audio_service/pubspec.yaml b/audio_service/pubspec.yaml index 6f2bdeb9..c91282b8 100644 --- a/audio_service/pubspec.yaml +++ b/audio_service/pubspec.yaml @@ -1,6 +1,6 @@ name: audio_service description: Flutter plugin to play audio in the background while the screen is off. -version: 0.18.18 +version: 0.18.19 repository: https://github.com/ryanheise/audio_service/tree/minor/audio_service issue_tracker: https://github.com/ryanheise/audio_service/issues topics: