banner



What App Uses A Figure Of A Man In A Hat.and Sunglasses As Notification Icon

Starting with 8.0 (API level 26), notification badges (also known as notification dots) appear on a launcher icon when the associated app has an active notification. Users can long-press on the app icon to reveal the notifications (alongside any app shortcuts), as shown in figure 1.

These dots appear by default in launcher apps that support them and there's nothing your app needs to do. However, there might be situations in which you don't want the to notification dot to appear or you want to control exactly which notifications to appear there.

Figure 1. Notification badges and the long-press menu

Disable badging

There are cases where badges don't make sense for your notifications, so you can disable them on a per-channel basis by calling setShowBadge(false) on your NotificationChannel object.

For example, you might want to disable notification badges in the following situations:

  • Ongoing notifications: Most ongoing notifications, such as image processing, media playback controls, or current navigation instructions, don't make sense as a badge.
  • Calendar reminders: Avoid badging events occurring at the current time.
  • Clock or alarm events: Avoid badging notifications related to current alarms.

The following sample code illustrates how to hide badges for a notification channel:

Kotlin

val id = "my_channel_01" val name = getString(R.string.channel_name) val descriptionText = getString(R.string.channel_description) val importance = NotificationManager.IMPORTANCE_LOW val mChannel = NotificationChannel(id, name, importance).apply {     description = descriptionText              setShowBadge(false)              } val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(mChannel)            

Java

String id = "my_channel_01"; CharSequence name = getString(R.string.channel_name); String description = getString(R.string.channel_description); int importance = NotificationManager.IMPORTANCE_LOW; NotificationChannel mChannel = new NotificationChannel(id, name, importance); mChannel.setDescription(description);              mChannel.setShowBadge(false);              NotificationManager notificationManager =         (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(mChannel);            

Set custom notification count

By default, each notification increments a number displayed on the long- press menu (visible in figure 1), but you can override this number for your app. For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages.

To set a custom number, call setNumber() on the notification, as shown here:

Kotlin

var notification = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID)         .setContentTitle("New Messages")         .setContentText("You've received 3 new messages.")         .setSmallIcon(R.drawable.ic_notify_status)              .setNumber(messageCount)              .build()            

Java

Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)         .setContentTitle("New Messages")         .setContentText("You've received 3 new messages.")         .setSmallIcon(R.drawable.ic_notify_status)              .setNumber(messageCount)              .build();            

The long-press menu displays the large or small icon associated with a notification if available. By default, the system displays the large icon, but you can call Notification.Builder.setBadgeIconType() and pass in the BADGE_ICON_SMALL constant to display the small icon.

Kotlin

var notification = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID)         .setContentTitle("New Messages")         .setContentText("You've received 3 new messages.")         .setSmallIcon(R.drawable.ic_notify_status)              .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)              .build()            

Java

Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)         .setContentTitle("New Messages")         .setContentText("You've received 3 new messages.")         .setSmallIcon(R.drawable.ic_notify_status)              .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)              .build();            

If your app creates a notification that duplicates an app shortcut, you can temporarily hide the shortcut while the notification is active by calling setShortcutId().

For more sample code that uses notifications, see the Android Notifications Sample.

What App Uses A Figure Of A Man In A Hat.and Sunglasses As Notification Icon

Source: https://developer.android.com/training/notify-user/badges

Posted by: franklinsart1949.blogspot.com

0 Response to "What App Uses A Figure Of A Man In A Hat.and Sunglasses As Notification Icon"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel