Reputation: 81
On Android, when creating a channel, there are two properties: setBypassDnd and setLockscreenVisibility, that are only modifiable by the system (https://developer.android.com/reference/android/app/NotificationChannel). I have tested creating a channel with those values:
if (Build.VERSION.SDK_INT >= 26) {
//we give it a name, description and importance
CharSequence name = context.getString(R.string.channel_name);
String channelID = getNotificationChannelID(getSharedPreferences(context));
NotificationChannel channel = new NotificationChannel(channelID, name, importance);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(VISIBILITY_SECRET);
// Register the channel with the system
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
But the values in the channel are set as per default (bypassDnd=false and LockscreenVisibility=VISIBILITY_PUBLIC) which I understand is caused by the "only modifiable by system" restriction.
I am recreating the channel as this seems to be the only way to change vibration/sound/LED after the channel is created, but I want to keep all the properties the user might have set.
I guess at this point this is a limitation I cannot overcome, but I am curious if anyone has found a way to work around this or this is just how it is.
Upvotes: 2
Views: 1038