@@ -101,15 +101,67 @@ public void run() {
101
101
NotificationManager nm = (NotificationManager )getSystemService (NOTIFICATION_SERVICE );
102
102
Intent newIntent = new Intent (this , getStubClass ());
103
103
PendingIntent contentIntent = PendingIntent .getActivity (this , 0 , newIntent , PendingIntent .FLAG_CANCEL_CURRENT );
104
-
104
+
105
+
106
+
105
107
Notification .Builder builder = new Notification .Builder (this )
106
108
.setContentIntent (contentIntent )
107
109
.setSmallIcon (android .R .drawable .stat_notify_sync )
108
110
.setTicker (value )
109
111
.setAutoCancel (true )
110
112
.setWhen (System .currentTimeMillis ())
111
113
.setContentTitle (value )
114
+
112
115
.setDefaults (Notification .DEFAULT_ALL );
116
+
117
+
118
+
119
+
120
+ // The following section is commented out so that builds against SDKs below 26
121
+ // won't fail.
122
+ /*<SDK26>
123
+ if(android.os.Build.VERSION.SDK_INT >= 21){
124
+ builder.setCategory("Notification");
125
+ }
126
+ if (android.os.Build.VERSION.SDK_INT >= 26) {
127
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
128
+
129
+ String id = Display.getInstance().getProperty("android.NotificationChannel.id", "cn1-channel");
130
+
131
+ CharSequence name = Display.getInstance().getProperty("android.NotificationChannel.name", "Notifications");
132
+
133
+ String description = Display.getInstance().getProperty("android.NotificationChannel.description", "Remote notifications");
134
+
135
+ int importance = Integer.parseInt(Display.getInstance().getProperty("android.NotificationChannel.importance", ""+NotificationManager.IMPORTANCE_LOW));
136
+
137
+ android.app.NotificationChannel mChannel = new android.app.NotificationChannel(id, name,importance);
138
+
139
+ mChannel.setDescription(description);
140
+
141
+ mChannel.enableLights(Boolean.parseBoolean(Display.getInstance().getProperty("android.NotificationChannel.enableLights", "true")));
142
+
143
+ mChannel.setLightColor(Integer.parseInt(Display.getInstance().getProperty("android.NotificationChannel.lightColor", ""+android.graphics.Color.RED)));
144
+
145
+ mChannel.enableVibration(Boolean.parseBoolean(Display.getInstance().getProperty("android.NotificationChannel.enableVibration", "false")));
146
+ String vibrationPatternStr = Display.getInstance().getProperty("android.NotificationChannel.vibrationPattern", null);
147
+ if (vibrationPatternStr != null) {
148
+ String[] parts = vibrationPatternStr.split(",");
149
+ int len = parts.length;
150
+ long[] pattern = new long[len];
151
+ for (int i=0; i<len; i++) {
152
+ pattern[i] = Long.parseLong(parts[i].trim());
153
+ }
154
+ mChannel.setVibrationPattern(pattern);
155
+ }
156
+
157
+
158
+
159
+ mNotificationManager.createNotificationChannel(mChannel);
160
+ System.out.println("Setting push channel to "+id);
161
+ builder.setChannelId(id);
162
+ }
163
+ </SDK26>*/
164
+
113
165
Notification notif = builder .build ();
114
166
nm .notify ((int )System .currentTimeMillis (), notif );
115
167
}
0 commit comments