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

前端 未结 8 1341
礼貌的吻别
礼貌的吻别 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:14

    I think I have learned a couple things that all add up to an answer:

    1. I was using an emulator device, with an image that did not include the Play Store.
    2. The version of Google Play Services on the image was not the latest, so I should have been getting a notification telling me I needed to upgrade. Since that notification didn't get applied to a channel, it didn't appear.
    3. If I set logcat in Android Studio to "No Filters" instead of "Show only selected application", then I found the logs that pointed out that the notification in question was the Play Services "update needed" notification.

    So, I changed to a image with the Play Store included, and it showed the notification properly (maybe the channel for that notification was to be set by the Play Store?), let me update to the latest Google Play Services, and I haven't seen that warning since.

    So, long story short (too late) - with Android O, if you are using Google Play Services & testing on the emulator, choose an image with the Play Store included, or ignore the toast (good luck on that one!).

    0 讨论(0)
  • 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);}
    
    0 讨论(0)
提交回复
热议问题