Skip to content

Commit 0997339

Browse files
committed
Safeguard thread recreation/start
1 parent 0075258 commit 0997339

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void initialize(Activity activity, NotificationCallback notificationCall
7777
mNotificationCallback = notificationCallback;
7878
if (mScheduledNotifications == null)
7979
mScheduledNotifications = new ConcurrentHashMap();
80-
if (mBackgroundThread == null)
80+
if (mBackgroundThread == null || !mBackgroundThread.isAlive())
8181
mBackgroundThread = new UnityNotificationBackgroundThread(this, mScheduledNotifications);
8282
if (mRandom == null)
8383
mRandom = new Random();
@@ -108,7 +108,8 @@ private void initialize(Activity activity, NotificationCallback notificationCall
108108
Log.e(TAG_UNITY, "Failed to load meta-data, NullPointer: " + e.getMessage());
109109
}
110110

111-
mBackgroundThread.start();
111+
if (!mBackgroundThread.isAlive())
112+
mBackgroundThread.start();
112113
}
113114

114115
static synchronized UnityNotificationManager getNotificationManagerImpl(Context context) {

0 commit comments

Comments
 (0)