为了账号安全,请及时绑定邮箱和手机立即绑定

通过标准 SDK 在 Android 8 上显示应用图标徽章

通过标准 SDK 在 Android 8 上显示应用图标徽章

喵喵时光机 2021-10-13 15:51:04
根据https://developer.android.com/training/notify-user/badges 从 Android 8 开始,操作系统允许设置应用程序图标通知徽章,但我无法让它工作。            NotificationManagerCompat nm = NotificationManagerCompat.from(activityContext);            if (Build.VERSION.SDK_INT >= 26) {                NotificationChannel nc = new NotificationChannel("ab", "chanelName", NotificationManager.IMPORTANCE_DEFAULT);                nc.setDescription("A chanel description here");                nc.setShowBadge(true);                NotificationManager nmm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);                nmm.createNotificationChannel(nc);            }            NotificationCompat.Builder nb = new NotificationCompat.Builder(App.instance, "ab");            nb.setSmallIcon(R.drawable.accept_icon);            nb.setTicker("here is the ticker");            nb.setContentText("Here content text");            nb.setContentTitle("Here content title");            nb.setNumber(5);            nb.setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL);            nm.notify(1, nb.build());我正在使用 Nexus 6P 和 android 8.1 。它在系统栏中显示通知,但不在应用程序图标上显示徽章。我错过了什么?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 229 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信