前提・実現したいこと
通知ドットに件数を表示したい。
発生している問題・エラーメッセージ
色付きのドットが表示されるだけで、数字が表示されない。
Notification.BuilderにsetNumberで件数を指定するだけではだめなのでしょうか?
該当のソースコード
Java
1String channelID = "channel"; // 通知チャンネルのIDにする任意の文字列 2String channelName = "Channel"; // 通知チャンネル名(ユーザーが設定でみることになるチャンネル名) 3int importance = android.app.NotificationManager.IMPORTANCE_HIGH; // 通知チャンネルの重要度 4 5// 複数の通知をチャンネルに振り分けて管理できるNotificationChannel 6NotificationChannel channel = new NotificationChannel(channelID, channelName, importance); 7 8channel.setDescription("通知チャンネルの説明"); 9channel.enableLights(true); // 通知時にライトを有効にする 10channel.setLightColor(Color.RED); // 通知時のライトの色 11channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); // ロック画面での表示レベル 12channel.enableVibration(true); // 通知時にバイブレーションを有効にする 13channel.setVibrationPattern(new long[]{100, 200, 300, 400, 300, 200}); // 通知時のバイブレーションの振動パターン 14channel.setShowBadge(true); 15 16// チャンネル登録をする。設定でみれるようにする。 17android.app.NotificationManager notificationManager = (android.app.NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 18notificationManager.createNotificationChannel(channel); 19 20Notification notification = new Notification.Builder(this, channelID) 21.setSmallIcon(R.drawable.small_icon) 22.setContentTitle("タイトル") 23.setContentText("本文") 24.setAutoCancel(true) 25.setNumber(1) 26.build(); 27 28// ユーザーに通知する。 29notificationManager.notify(R.string.app_name, notification);
補足情報(FW/ツールのバージョンなど)
Android 8.0
HUAWEI P10 lite
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/22 02:53