From 8aaa766dcd61d7657356a09fa60ac5f9624c09cc Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Sun, 4 Feb 2024 20:35:40 +0100 Subject: [PATCH] Fix crash when receiving empty music state --- .../externalevents/NotificationListener.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index 1dc673a45..3727d6f2c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -700,15 +700,17 @@ public class NotificationListener extends NotificationListenerService { }; mHandler.postDelayed(mSetMusicInfoRunnable, 100); - if (mSetMusicStateRunnable != null) { - mHandler.removeCallbacks(mSetMusicStateRunnable); - } - mSetMusicStateRunnable = new Runnable() { - @Override - public void run() { - GBApplication.deviceService().onSetMusicState(stateSpec); + if (stateSpec != null) { + if (mSetMusicStateRunnable != null) { + mHandler.removeCallbacks(mSetMusicStateRunnable); } - }; + mSetMusicStateRunnable = new Runnable() { + @Override + public void run() { + GBApplication.deviceService().onSetMusicState(stateSpec); + } + }; + } mHandler.postDelayed(mSetMusicStateRunnable, 100); return true;