Java 如何在appview android上仅显示通知计数
我不熟悉安卓系统。为了在android手机上显示通知,我得到了以下代码Java 如何在appview android上仅显示通知计数,java,android,android-notifications,Java,Android,Android Notifications,我不熟悉安卓系统。为了在android手机上显示通知,我得到了以下代码 Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /*Request code*/ , intent,
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /*Request code*/ , intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.mytune_default)
.setContentTitle("FCM Message")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int m = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
notificationManager.notify(m /*ID of notification*/ , notificationBuilder.build());
但问题是,我只希望系统上的代码appview中包含未读的通知,但不希望系统的通知托盘上出现其他内容,如消息、标题等。这是怎么实现的>不可能用小部件替换启动器图标。您可以告诉用户将小部件放在主屏幕上,但不放在应用程序列表中。用户必须自己完成这项工作。然而,这是iOs模式。将iOS设计元素引入android不是个好主意。Android有很棒的通知栏,用户可以在这里看到应用程序发出的通知。Android用户不希望通过图标看到它。loke?另外,我也不太明白你想问什么。我只想在appview上显示通知计数,但不想在Phone上的通知栏上显示消息,但当我使用上述代码时,它同时在应用图标和通知栏上显示通知。我可以只在应用图标中显示通知而不在通知栏中显示通知吗?不可能。