Skip to content

Commit a959c6b

Browse files
authored
Kotlin sample app: Fix Null Pointer Exception when rotating the screen. (#138)
1 parent 477b1ba commit a959c6b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

samples/kotlin-android-app/src/main/java/com/segment/analytics/next/plugins/PushNotificationTracking.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlinx.serialization.json.put
1616
* opening of that notification and fire the Push Notification Tapped event.
1717
*/
1818

19-
object PushNotificationTracking: Plugin, AndroidLifecycle {
19+
object PushNotificationTracking : Plugin, AndroidLifecycle {
2020
override val type: Plugin.Type = Plugin.Type.Utility
2121
override lateinit var analytics: Analytics
2222

@@ -25,8 +25,12 @@ object PushNotificationTracking: Plugin, AndroidLifecycle {
2525
activity?.intent?.extras
2626
} else {
2727
Bundle().apply {
28-
putAll(savedInstanceState)
29-
putAll(activity?.intent?.extras)
28+
if (savedInstanceState != null) {
29+
putAll(savedInstanceState)
30+
}
31+
if (activity?.intent?.extras != null) {
32+
putAll(activity?.intent?.extras)
33+
}
3034
}
3135
}
3236
checkPushNotification(bundle)

0 commit comments

Comments
 (0)