首页 > 其他 > 详细

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

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

 

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());
 

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!