Android O reporting notification not posted to channel - but it is

前端 未结 8 1398
礼貌的吻别
礼貌的吻别 2020-12-05 06:52

Couple Android O notification questions:

1) I have created a Notification Channel (see below), am calling the builder with .setChannelId() (passing in the name of th

8条回答
  •  孤街浪徒
    2020-12-05 07:16

    I had the same problem, and resolved it by using the constructor

    new Notification.Builder(Context context, String channelId), instead of the one which is deprecated onAPI levels >=26 (Android O) : new NotificationCompat.Builder(Context context)

    The following code won't work if your notificationBuilder is built using the deprecated constructor :

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
    notificationBuilder.setChannelId(NOTIFICATION_CHANNEL);}
    

提交回复
热议问题