亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過標準 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 關注
  • 248 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號