From 351a1aba24e7915dc8b46b3a2410ac415f5cf5e4 Mon Sep 17 00:00:00 2001 From: Matin Zadehdolatabad Date: Fri, 24 May 2019 19:52:50 +0430 Subject: [PATCH] fix: Illegal null AudioFocusRequest exception (#261) * Fix #260 on native call --- .../tanguyantoine/react/MusicControlAudioFocusListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/tanguyantoine/react/MusicControlAudioFocusListener.java b/android/src/main/java/com/tanguyantoine/react/MusicControlAudioFocusListener.java index 949451fb..ba0bc89b 100644 --- a/android/src/main/java/com/tanguyantoine/react/MusicControlAudioFocusListener.java +++ b/android/src/main/java/com/tanguyantoine/react/MusicControlAudioFocusListener.java @@ -50,9 +50,9 @@ public void requestAudioFocus() { } public void abandonAudioFocus() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mAudioManager != null) { mAudioManager.abandonAudioFocusRequest(mFocusRequest); - } else { + } else if ( mAudioManager != null ) { mAudioManager.abandonAudioFocus(this); } }