# HG changeset patch # User Carl Byington # Date 1602700034 25200 # Node ID 869070df0e80fef3aa3bf3bcc46dfda10ee09c7f # Parent 3afdeb535e9f70989b51a6f5314f376ed2c1e8fc new notification channel needs android 8 diff -r 3afdeb535e9f -r 869070df0e80 app/build.gradle --- a/app/build.gradle Wed Oct 14 11:11:09 2020 -0700 +++ b/app/build.gradle Wed Oct 14 11:27:14 2020 -0700 @@ -60,7 +60,7 @@ defaultConfig { applicationId = "com.five_ten_sg.connectbot" - minSdkVersion = 21 + minSdkVersion = 26 targetSdkVersion = 28 ndk { moduleName = "com_google_ase_Exec" diff -r 3afdeb535e9f -r 869070df0e80 app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java --- a/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 11:11:09 2020 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/service/ConnectionNotifier.java Wed Oct 14 11:27:14 2020 -0700 @@ -40,6 +40,7 @@ public class ConnectionNotifier { private static final int ONLINE_NOTIFICATION = 1; private static final int ACTIVITY_NOTIFICATION = 2; + private NotificationChannel chan = null; protected NotificationManager getNotificationManager(Context context) { return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); @@ -61,13 +62,14 @@ String channelID = "com.five_ten_sg.connectbot.service"; String channelName = "background"; - NotificationChannel chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); - chan.setLightColor(R.color.colorAccent); - chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); - - NotificationManager manager = getNotificationManager(context); - assert manager != null; - manager.createNotificationChannel(chan); + if (chan == null) { + chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); + chan.setLightColor(R.color.colorAccent); + chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + NotificationManager manager = getNotificationManager(context); + assert manager != null; + manager.createNotificationChannel(chan); + } Notification notification = new Notification.Builder(context) .setContentTitle(res.getString(R.string.app_name)) @@ -90,13 +92,14 @@ String channelID = "com.five_ten_sg.connectbot.service"; String channelName = "background"; - NotificationChannel chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); - chan.setLightColor(R.color.colorAccent); - chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); - - NotificationManager manager = getNotificationManager(context); - assert manager != null; - manager.createNotificationChannel(chan); + if (chan == null) { + chan = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_NONE); + chan.setLightColor(R.color.colorAccent); + chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + NotificationManager manager = getNotificationManager(context); + assert manager != null; + manager.createNotificationChannel(chan); + } Notification notification = new Notification.Builder(context) .setContentTitle(res.getString(R.string.app_name))