码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-12-28 11:37:30      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:new   message   show   tsm   draw   ring   ica   通知   style   

 

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的话,则不会出现.

 

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

标签:new   message   show   tsm   draw   ring   ica   通知   style   

原文地址:https://www.cnblogs.com/lipeineng/p/12111017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!