Android - 仅显示抬头通知

时间:2018-04-01 18:58:33

标签: java android notifications

我只想展示我从FCM获得的抬头通知,我不想在通知列表中显示通知本身。

这可能吗?

我不想这样显示通知。

enter image description here

以下是代码:

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.view_achievement_congratulations);
contentView.setImageViewResource(R.id.viewAchievementCongrats_image, R.drawable.ic_conquista_desbloqueada);
contentView.setTextViewText(R.id.viewAchievementConquest_tvTitle, PrefsManager.getInstance().getAchievementNotification().getText());

if (PrefsManager.getInstance().getAchievementsCount() == 1) {
    contentView.setTextViewText(R.id.viewAchievementConquest_tvDescription, Html.fromHtml(PrefsManager.getInstance().getAchievementNotification().getDescription()));
} else {
    contentView.setTextViewText(R.id.viewAchievementConquest_tvDescription, );
}

Intent notificationIntent = new Intent(this, AchievementsActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.icon_pin_homer)
        .setContentIntent(contentIntent)
        .setContent(contentView)
        .setDefaults(Notification.DEFAULT_ALL)
        .setPriority(NotificationManager.IMPORTANCE_HIGH);

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, builder.build());

抬头通知已经显示(这很好):)

0 个答案:

没有答案