diff --git a/android/app/src/main/java/tf/monochrome/music/BackgroundAudioPlugin.java b/android/app/src/main/java/tf/monochrome/music/BackgroundAudioPlugin.java index afb5d76..42a6b43 100644 --- a/android/app/src/main/java/tf/monochrome/music/BackgroundAudioPlugin.java +++ b/android/app/src/main/java/tf/monochrome/music/BackgroundAudioPlugin.java @@ -32,11 +32,16 @@ public class BackgroundAudioPlugin extends Plugin { } } - @PluginMethod + `@PluginMethod` public void stop(PluginCall call) { - Intent intent = new Intent(getContext(), AudioPlaybackService.class); - intent.setAction("STOP"); - getContext().stopService(intent); - call.resolve(); + try { + Intent intent = new Intent(getContext(), AudioPlaybackService.class); + intent.setAction("STOP"); + // Use startService so onStartCommand receives the STOP action + getContext().startService(intent); + call.resolve(); + } catch (Exception e) { + call.reject("Failed to stop audio service: " + e.getMessage(), e); + } } }