From c263cc89ff3af5dbab985c24dab31a40d40c8025 Mon Sep 17 00:00:00 2001 From: Jay Kim Date: Wed, 14 Dec 2022 13:26:29 +0900 Subject: [PATCH] fix(android): check null activity If activity is null at initialization, the app crashes. This change checks for null activity and throw react native error, which prevents app crash. --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 27a79782..05b09d7a 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -572,6 +572,12 @@ class ReactExoplayerView extends FrameLayout implements eventEmitter.error("Failed to initialize DRM Session Manager Framework!", new Exception("DRM Session Manager Framework failure!"), "3003"); return; } + + if (activity == null) { + Log.e("ExoPlayer Exception", "Failed to initialize Player!"); + eventEmitter.error("Failed to initialize Player!", new Exception("Current Activity is null!"), "1001"); + return; + } // Initialize handler to run on the main thread activity.runOnUiThread(new Runnable() {