根據(jù)https://developer.android.com/training/notify-user/badges 從 Android 8 開始,操作系統(tǒng)允許設(shè)置應(yīng)用程序圖標(biāo)通知徽章,但我無法讓它工作。 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 。它在系統(tǒng)欄中顯示通知,但不在應(yīng)用程序圖標(biāo)上顯示徽章。我錯(cuò)過了什么?
通過標(biāo)準(zhǔn) SDK 在 Android 8 上顯示應(yīng)用圖標(biāo)徽章
喵喵時(shí)光機(jī)
2021-10-13 15:51:04