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
80
votes
3 answers

Changing notification icon background on Lollipop

I was going through the Notifications design pattern, and didn't find anything that talks about notification icon background. As you probably noticed, there is only a light grey background for custom notifications. But apps like Hangouts, or simply…
Zsolt Boldizsar
  • 2,447
  • 2
  • 27
  • 37
76
votes
3 answers

Prevent user from dismissing notification

Some apps have notifications which can´t be dismissed by swiping them away. How can I manage such behaviour?
Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
74
votes
13 answers

Firebase FCM notifications click_action payload

I am trying to open a particular activity when the user clicks the notification when the app is in the background. From the Docs, I have got that click_action has to be added in the payload and an intent filter in the App to handle it. But, how to…
73
votes
9 answers

Load image from url in notification Android

In my android application, i want to set Notification icons dynamically which will be loaded from URL. For that, i have used setLargeIcon property of NotificationBuilder in receiver.I reffered many link and tried various solutions but couldn't get…
70
votes
11 answers

Android Color Notification Icon

I'm working on an app where I create a notification for the user. I want the icon to appear as white when it's in the status bar, but colored blue when it's being displayed in the drop down notification menu. Here's an example of the same thing…
Oblivionkey3
  • 1,752
  • 2
  • 17
  • 25
65
votes
3 answers

Update text of notification, not entire notification

Prelude I'm trying to add a chronometer on the notification. The chronometer is a service. Every second this line is called (continue Thread is a the "running" boolean, timeString is the elaborated String showing the…
David Corsalini
  • 7,958
  • 8
  • 41
  • 66
62
votes
8 answers

Android Notification PendingIntent Extras null

I am trying to send information from notification to invoked activity, while from my activity I got null. The code for notification is: private void showNotification() { Intent resultIntent = new Intent(this, MainActivity.class); if (D) …
61
votes
9 answers

How to create a notification with NotificationCompat.Builder?

I need to create a simple notification which will be shown in notification bar along with the sound and icon if possible? I also need it to be compatitible with Android 2.2, so i found that NotificationCompat.Builder works with all APIs above 4. If…
59
votes
5 answers

How to open fragment page, when pressed a notification in android

I am trying to open a fragment when I press a notification in the notification bar. My app structure is: a base activity with a nav drawer menu some fragment that are opened from menu b.setOnClickListener(new OnClickListener() { …
58
votes
5 answers

NotificationCompat with API 26

I dont see any information about how to use NotificationCompat with Android O's Notification Channels I do see a new Constructor that takes a channelId but how to take a Compat notification and use it in a NotificationChannel since…
tyczj
  • 71,600
  • 54
  • 194
  • 296
58
votes
5 answers

Clicking Android Notification Actions does not close Notification drawer

I am adding a Notification to System bar using the NotificationCompat library. This Notification has two action buttons. Also, AutoCancel() property on the Notification is set to true. On Click of the action buttons, System is configured to launch…
Aster
  • 591
  • 1
  • 4
  • 5
58
votes
7 answers

Intent from notification does not have extras

This seem to be a common problem and I went through all the related questions I could find already: Activity isn't picking up new intent, Why extra data (integer) is not sent in android notification intent?, Notification passes old Intent Extras,…
Matthieu
  • 16,103
  • 10
  • 59
  • 86
57
votes
6 answers

Flutter: Push notifications even if the app is closed

I have built an application with flutter that works like a reminder. How can I display notifications to the user even though the app is closed?
54
votes
9 answers

Heads-up Notification - Android Lollipop

I'm trying to show a notification-type heads-up but I could not. What I tried final Notification.Builder notif = new Builder(getApplicationContext()) .setContentTitle(getString(R.string.title)) .setContentText(getString(R.string.text)) // …
user1719863
  • 787
  • 1
  • 8
  • 13
54
votes
1 answer

Can NoticationManager.notify() be called from a worker thread?

My question is more about what is a good practice than what is possible: Is it a good thing to call NoticationManager.notify() from a worker thread? Does the system execute it in the UI thread anyway or not? I always try to keep in mind that stuff…
Joffrey
  • 32,348
  • 6
  • 68
  • 100