Failed to post notification on channel “null” Target Api is 26

前端 未结 8 858
盖世英雄少女心
盖世英雄少女心 2020-12-08 06:53

Two log showing

1: Use of stream types is deprecated for operations other than volume control

2: See the documentation of setSound() for what to use instea

8条回答
  •  臣服心动
    2020-12-08 07:09

    If you get this error should be paid attention to 2 items and them order:

    1. NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    2. builder = new NotificationCompat.Builder(this, id);

    Also NotificationManager notifManager and NotificationChannel mChannel are created only once.

    There are required setters for Notification:

    builder.setContentTitle() // required  
           .setSmallIcon()    // required 
           .setContentText()  // required  
    

    See the example in On Android 8.1 API 27 notification does not display.

提交回复
热议问题