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.
This commit is contained in:
Jay Kim 2022-12-14 13:26:29 +09:00 committed by GitHub
parent 133ede773e
commit c263cc89ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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() {