Default priority of notification channel on Android 8

江枫思渺然 提交于 2019-12-23 20:08:41

问题


I am in the process of changing the target SDK version to 26 and trying to use notification channels. I have some notifications for which I would like to hide the icon in the notification bar. Is this possible by default using Notification channels? Even if I set the channel's importance (and the notification's priority to MIN), the icon is displayed. I can then long click the notification and go to the system settings for notifications in my app. Then click the notification channel and then importance, which has "Medium" (German "Mittel", might as well be called "Default" in English) selected. Shouldn't this importance be "low"?

This is how I set up the channel (using Mono for Android):

            string name = GetString(Resource.String.DbQuicklockedChannel_name);
            string desc = GetString(Resource.String.DbQuicklockedChannel_desc);
            NotificationChannel mChannel =
                new NotificationChannel(NotificationChannelIdQuicklocked, name, NotificationImportance.Min);
            mChannel.Description = desc;
            mChannel.EnableLights(false);
            mChannel.EnableVibration(false);
            mNotificationManager.CreateNotificationChannel(mChannel);

回答1:


It turned out that this is not respected because I am starting the notification with StartForeground. This is documented on https://developer.android.com/reference/android/app/NotificationManager.html#IMPORTANCE_MIN.



来源:https://stackoverflow.com/questions/48704448/default-priority-of-notification-channel-on-android-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!