@@ -63,19 +63,35 @@ private void createNotificationChannel(String channelId, String channelName, Str
63
63
}
64
64
}
65
65
}
66
+ public enum NotificationPriority {
67
+ DEFAULT (NotificationCompat .PRIORITY_DEFAULT ),
68
+ MIN (NotificationCompat .PRIORITY_MIN ),
69
+ LOW (NotificationCompat .PRIORITY_LOW ),
70
+ HIGH (NotificationCompat .PRIORITY_HIGH ),
71
+ MAX (NotificationCompat .PRIORITY_MAX );
66
72
73
+ private int priority ;
74
+ NotificationPriority (int priority ) {
75
+ this .priority = priority ;
76
+ }
77
+
78
+ public int getPriority () {
79
+ return priority ;
80
+ }
81
+ }
67
82
/**
68
83
* Displays a notification.
69
- *
84
+ *
70
85
* @param icon The icon resource ID of the notification.
71
86
* @param text The text content of the notification.
72
87
* @param notificationId The ID of the notification.
88
+ * @param priority The priority of the notification.
73
89
*/
74
- public void showNotification (int icon , String text , int notificationId ) {
90
+ public void showNotification (int icon , String text , int notificationId , NotificationPriority priority ) {
75
91
NotificationCompat .Builder builder = new NotificationCompat .Builder (context , channelId )
76
92
.setSmallIcon (icon )
77
93
.setContentText (text )
78
- .setPriority (NotificationCompat . PRIORITY_DEFAULT )
94
+ .setPriority (priority . getPriority () )
79
95
.setAutoCancel (true );
80
96
81
97
NotificationManagerCompat notificationManager = NotificationManagerCompat .from (context );
0 commit comments