@@ -872,6 +872,18 @@ public static AndroidJavaObject CreateNotificationBuilder(AndroidNotification no
872
872
/// <param name="channelId">Channel id</param>
873
873
/// <returns>A proxy object for created Notification.Builder</returns>
874
874
public static AndroidJavaObject CreateNotificationBuilder ( int id , AndroidNotification notification , string channelId )
875
+ {
876
+ AndroidJavaObject builder , extras ;
877
+ CreateNotificationBuilder ( notification , channelId , out builder , out extras ) ;
878
+ if ( extras != null )
879
+ {
880
+ s_Jni . Bundle . PutInt ( extras , s_Jni . NotificationManager . KEY_ID , id ) ;
881
+ extras . Dispose ( ) ;
882
+ }
883
+ return builder ;
884
+ }
885
+
886
+ static void CreateNotificationBuilder ( AndroidNotification notification , string channelId , out AndroidJavaObject notificationBuilder , out AndroidJavaObject extras )
875
887
{
876
888
long fireTime = notification . FireTime . ToLong ( ) ;
877
889
if ( fireTime < 0L )
@@ -881,7 +893,7 @@ public static AndroidJavaObject CreateNotificationBuilder(int id, AndroidNotific
881
893
882
894
// NOTE: JNI calls are expensive, so we avoid calls that set something that is also a default
883
895
884
- var notificationBuilder = s_Jni . NotificationManager . CreateNotificationBuilder ( channelId ) ;
896
+ notificationBuilder = s_Jni . NotificationManager . CreateNotificationBuilder ( channelId ) ;
885
897
s_Jni . NotificationManager . SetNotificationIcon ( notificationBuilder , s_Jni . NotificationManager . KEY_SMALL_ICON , notification . SmallIcon ) ;
886
898
if ( ! string . IsNullOrEmpty ( notification . LargeIcon ) )
887
899
s_Jni . NotificationManager . SetNotificationIcon ( notificationBuilder , s_Jni . NotificationManager . KEY_LARGE_ICON , notification . LargeIcon ) ;
@@ -919,17 +931,12 @@ public static AndroidJavaObject CreateNotificationBuilder(int id, AndroidNotific
919
931
if ( notification . GroupAlertBehaviour != GroupAlertBehaviours . GroupAlertAll ) // All is default value
920
932
s_Jni . NotificationManager . SetNotificationGroupAlertBehavior ( notificationBuilder , ( int ) notification . GroupAlertBehaviour ) ;
921
933
922
- using ( var extras = s_Jni . NotificationBuilder . GetExtras ( notificationBuilder ) )
923
- {
924
- s_Jni . Bundle . PutInt ( extras , s_Jni . NotificationManager . KEY_ID , id ) ;
925
- s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , notification . RepeatInterval . ToLong ( ) ) ;
926
- s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , fireTime ) ;
927
- s_Jni . Bundle . PutBoolean ( extras , s_Jni . NotificationManager . KEY_SHOW_IN_FOREGROUND , notification . ShowInForeground ) ;
928
- if ( ! string . IsNullOrEmpty ( notification . IntentData ) )
929
- s_Jni . Bundle . PutString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA , notification . IntentData ) ;
930
- }
931
-
932
- return notificationBuilder ;
934
+ extras = s_Jni . NotificationBuilder . GetExtras ( notificationBuilder ) ;
935
+ s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_REPEAT_INTERVAL , notification . RepeatInterval . ToLong ( ) ) ;
936
+ s_Jni . Bundle . PutLong ( extras , s_Jni . NotificationManager . KEY_FIRE_TIME , fireTime ) ;
937
+ s_Jni . Bundle . PutBoolean ( extras , s_Jni . NotificationManager . KEY_SHOW_IN_FOREGROUND , notification . ShowInForeground ) ;
938
+ if ( ! string . IsNullOrEmpty ( notification . IntentData ) )
939
+ s_Jni . Bundle . PutString ( extras , s_Jni . NotificationManager . KEY_INTENT_DATA , notification . IntentData ) ;
933
940
}
934
941
935
942
internal static AndroidNotificationIntentData GetNotificationData ( AndroidJavaObject notificationObj )
0 commit comments