Skip to content

Commit 2eeae60

Browse files
committed
Properly dispose player class once no longer needed
1 parent 2bc4cd0 commit 2eeae60

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

com.unity.mobile.notifications/Runtime/Android/AndroidNotificationCenter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ public static bool Initialize()
568568
#if UNITY_EDITOR || !UNITY_ANDROID
569569
s_CurrentActivity = null;
570570
#elif UNITY_ANDROID
571-
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
572-
s_CurrentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
571+
using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
572+
s_CurrentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
573573

574574
var notificationManagerClass = new AndroidJavaClass("com.unity.androidnotifications.UnityNotificationManager");
575575
var notificationManager = notificationManagerClass.CallStatic<AndroidJavaObject>("getNotificationManagerImpl", s_CurrentActivity, new NotificationCallback());

0 commit comments

Comments
 (0)