Questions tagged [android-notifications]

A status notification adds an icon to the system's status bar (with an optional ticker-text message) and a notification message in the notifications window.

A notification is a user interface element that you display outside your app's normal UI to indicate that an event has occurred. Users can choose to view the notification while using other apps and respond to it when it's convenient for them.

Think of notifications as a news channel that alerts the user to important events as they happen or a log that chronicles events while the user is not paying attention. The user can expand the notification bar and by selecting the notification the user can trigger another activity. Notifications in Android are represented by the Notification class. To create notifications you use the NotificationManager class which can be received from the Activity via the getSystemService() method.

Useful links

4920 questions
11
votes
2 answers

NavDeepLinkBuilder destination ignored when app not in foreground

I am using NavDeepLinkBuilder to generate a pending intent for a push notification to open the app at a particular destination. return NavDeepLinkBuilder(this) .setComponentName(MainActivity::class.java) …
11
votes
3 answers

android notification channel sound not working

I know there has be a lot of post about the issue. I have tried them all. Here are the steps I did. First I found out that once a channel has been created it can't be change. The only way was to reinstall the app. So that's what I did and it did not…
thenewbie
  • 755
  • 19
  • 40
11
votes
2 answers

Android: Is it possible to update a ImageView/ImageButton with a number to show the number of new messages?

In iOS we have a feature to update the app icon with the new pending messages for the user by showing a small number on the right-top corner of the icon and similarly I would like to know if we have method to update a ImageView/ImageButton in…
Sana
  • 9,895
  • 15
  • 59
  • 87
11
votes
2 answers

Is there any way to get the device notification history?

I'm developing an usage statistics app and I'm wondering how other apps can access to the devices notification history. Right now I'm working with NotificationListenerService, but this only can handle the new notifications received, not the past…
11
votes
3 answers

startForegroundService() did not call startForeground(), but it did

I'm having the Context.startForegroundService() did not then call Service.startForeground() in my Android service, but I cannot figure out why it is happening. My application is for media streaming, and this error only occurs when you pause from the…
11
votes
1 answer

NotificationManagerCompat vs NotificationManager

What backwards compatibility does NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); provide that I don't get from the normal NotificationManager notificationManager = (NotificationManager)…
11
votes
1 answer

Background execution not allowed. Android O pendingintent

I have a service that schedules a pendingintent which starts my notification. However, since Android O I am getting this error. I did some research, and stumbled upon context.registerReceiver , but that does not seem to fix the…
11
votes
0 answers

How to use data binding on notification with RemoteViews

Is it possible to use data binding on custom Android notification layouts? I'm making a custom Android notification layout using RemoteViews as described here. We usually use data binding on our layouts, but it requires inflating it…
ScottyC
  • 1,467
  • 1
  • 15
  • 22
11
votes
5 answers

How to disable/re-enable the vibration that occurs on receiving notification?

I am defining a custom vibration for a specific functionality when notification is received. However, when the phone screen is off, the custom vibration plays along with the default notification vibration. I tried to put phone to silent mode and…
SoulRayder
  • 5,072
  • 6
  • 47
  • 93
11
votes
2 answers

I schedule a local Notification at specific time, using switch but its not triggering at set time

I'm using a switch which, when turned on will trigger alarm and start the notifications. Initially It worked fine and triggered the alarm at set time. After changing time manually, it started working weird notification is triggering instantly when…
Praneeth
  • 1,260
  • 18
  • 37
11
votes
4 answers

How to display multiple notification as a group?

here is my code for notification. it generate a new notification each time Random random = new Random(); int m = random.nextInt(9999 - 1000); NotificationCompat.Builder mBuilder =new NotificationCompat.Builder(context) …
sam chaudhari
  • 756
  • 1
  • 12
  • 24
11
votes
1 answer

Handling status bar notification before it is displayed

I am using NotificationListenerService to handle device notifications: @Override public void onNotificationPosted(StatusBarNotification sbn) { Log.d(TAG,"onNotificationPosted posted - ID :" + sbn.getId() + "\t" +…
Michael A
  • 5,770
  • 16
  • 75
  • 127
11
votes
1 answer

Size of MediaStyle LargeIcon

I'm implementing a Lollipop-style notification to a FTP streaming music player app using the new Notification.MediaStyle class. I am setting the album art as my "large icon". Given that the album art is taken directly from the file currently being…
initramfs
  • 8,275
  • 2
  • 36
  • 58
11
votes
1 answer

How to handle mixed RTL & LTR languages in notifications?

Background Android 4.3 has added a lot of support for RTL (Right-To-Left) languages, such as Hebrew and Arabic. The problem Even though there is "textDirection", "layoutDirection" and "gravity", I can't find the equivalents for the notification…
11
votes
1 answer

Is setContentIntent(PendingIntent) required in NotificationCompat.Builder?

Calling : public static void triggerTestNotification(Context ctx, String tag, int id) { Notification not = new NotificationCompat.Builder(ctx) .setContentTitle("Title").setContentText("Text") .setAutoCancel(true) // cancel on…
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361