解决Fail to post notification on channel "null"的方法
Posted lipeineng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决Fail to post notification on channel "null"的方法相关的知识,希望对你有一定的参考价值。
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"的方法的主要内容,如果未能解决你的问题,请参考以下文章