当前位置: 移动技术网 > IT编程>移动开发>Android > 解决Fail to post notification on channel "null"的方法

解决Fail to post notification on channel "null"的方法

2019年12月28日  | 移动技术网IT编程  | 我要评论

星海人才网,瑜媞,天堂伞官方旗舰店

 

mnotifymgr = (notificationmanager) getsystemservice(notification_service);
mnotifymgr.cancelall();
string title = getstring(r.string.filtershow_notification_label);
        if(build.version.sdk_int >= build.version_codes.o) {
            string id = "channel_1";
            notificationchannel channel = new notificationchannel(id, title, notificationmanager.importance_high);
            mnotifymgr.createnotificationchannel(channel);
            mbuilder = new notification.builder(this, id)
                    .setcategory(notification.category_event)
                    .setsmallicon(r.drawable.filtershow_button_fx)
                    .setcontenttitle(title)
                    .setcontenttext(getstring(r.string.filtershow_notification_message))
                    .setautocancel(true);
        } else {
            mbuilder = new notification.builder(this)
                    .setsmallicon(r.drawable.filtershow_button_fx)
                    .setcontenttitle(title)
                    .setcontenttext(getstring(r.string.filtershow_notification_message));
        }
mnotifymgr.notify(mnotificationid, mbuilder.build());
 
mnotificationid为1的话,systemui下拉栏会存在对应的通知item(可以用来点击跳转),
如果是0的话,则不会出现.

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网