zoukankan      html  css  js  c++  java
  • 解决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的话,则不会出现.
  • 相关阅读:
    [POI2010]Divine Divisor
    JOISC2014B たのしい家庭菜園
    Problem. C
    AGC004F Namori
    AGC007F Shik and Copying String
    AGC027C ABland Yard
    AGC028E High Elements
    JOI2017FinalE 縄
    CF797F Mice and Holes
    Problem. B
  • 原文地址:https://www.cnblogs.com/lipeineng/p/12111017.html
Copyright © 2011-2022 走看看