前提・実現したいこと
Android8.0で追加された通知ドットを利用しようとしています。
発生している問題・エラーメッセージ
push通知自体は表示されるのですが、アプリアイコンの上に表示される通知ドットが表示されません。
端末が利用しているランチャーアプリに依存してしまうのでしょうか?
該当のソースコード
String channelID = "channel"; // 通知チャンネルのIDにする任意の文字列 String channelName = "Channel"; // 通知チャンネル名(ユーザーが設定でみることになるチャンネル名) int importance = android.app.NotificationManager.IMPORTANCE_HIGH; // 通知チャンネルの重要度 // 複数の通知をチャンネルに振り分けて管理できるNotificationChannel NotificationChannel channel = new NotificationChannel(channelID, channelName, importance); channel.setDescription("通知チャンネルの説明"); channel.enableLights(true); // 通知時にライトを有効にする channel.setLightColor(Color.RED); // 通知時のライトの色 channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); // ロック画面での表示レベル channel.enableVibration(true); // 通知時にバイブレーションを有効にする channel.setVibrationPattern(new long[]{100, 200, 300, 400, 300, 200}); // 通知時のバイブレーションの振動パターン channel.setShowBadge(true); // チャンネル登録をする。設定でみれるようにする。 android.app.NotificationManager notificationManager = (android.app.NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(channel); Notification notification = new Notification.Builder(this, channelID) .setSmallIcon(R.drawable.small_icon) .setContentTitle("タイトル") .setContentText("本文") .setAutoCancel(true) .setNumber(1) .build(); // ユーザーに通知する。 notificationManager.notify(R.string.app_name, notification);
補足情報(FW/ツールのバージョンなど)
Android8.0
ランチャーアプリ:Huaweiホーム
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。