@@ -19,6 +19,9 @@ protected void onCreate(Bundle savedInstanceState)
19
19
20
20
public boolean onPreferenceTreeClick (PreferenceScreen preferenceScreen , Preference preference )
21
21
{
22
+ int NOTIFICATION_ID = 0 ;
23
+ String CHANNEL_ID = "notifikator" ;
24
+
22
25
Resources res = getResources ();
23
26
if (res .getString (R .string .key_send ).equals (preference .getKey ()))
24
27
{
@@ -33,7 +36,22 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
33
36
Bitmap largeIconBitmap = largeIconDrawable .getBitmap ();
34
37
nb .setLargeIcon (largeIconBitmap );
35
38
36
- mgr .notify (0 , nb .build ());
39
+ // `VERSION_CODES.O` means SDK 26
40
+ // Thanks Google, very readable
41
+ if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .O ) {
42
+ // notification channel setup
43
+ NotificationChannel mChannel = null ;
44
+ mChannel = new NotificationChannel (CHANNEL_ID , CHANNEL_ID , NotificationManager .IMPORTANCE_LOW );
45
+ mChannel .setDescription ("" );
46
+ mChannel .enableLights (true );
47
+ mChannel .setLightColor (Color .GREEN );
48
+ mChannel .enableVibration (false );
49
+ mgr .createNotificationChannel (mChannel );
50
+
51
+ nb .setChannelId (CHANNEL_ID );
52
+ }
53
+
54
+ mgr .notify (NOTIFICATION_ID , nb .build ());
37
55
return false ;
38
56
}
39
57
0 commit comments