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
28
votes
9 answers

Custom Notification Sound not working in Android Oreo

Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() + "/" + R.raw.notification_mp3); mBuilder.setSound(sound); I had copied the mp3 (notification_mp3.mp3) file into the raw folder in the res…
Ashish John
  • 1,867
  • 2
  • 23
  • 38
28
votes
2 answers

Crash when using ConstraintLayout in Notification

I get an InflationException when I use a ConstraintLayout in a custom Notification. I can use them elsewhere in my app, just not in a custom layout for a Notification. I'm assuming that any widget contained in a support library simply can't be used…
Sky Kelsey
  • 19,192
  • 5
  • 36
  • 77
28
votes
6 answers

Android O - Notification Channels and NotificationCompat

I cannot change this feeling: again, the Android developers came up with something new and leave everybody in the dark about how they would think the feature is used. I am talking about Notification Channels in Android O. For years I have been using…
28
votes
1 answer

Notification throws error when using vector drawables

I get the following exception when I use a vector drawable to set the small icon for a notification : android.app.RemoteServiceException: Bad notification posted from package com.qbes.xxx: Couldn't create icon: StatusBarIcon(pkg=com.qbes.xxxuser=0…
28
votes
2 answers

Why NotificationManagerCompat::cancelAll() gets SecurityException?

Using NotificationManagerCompat to cancel all notification. NotificationManagerCompat manager = NotificationManagerCompat.from(ctx.getApplicationContext()); manager.cancelAll(); It got exception some time (most time works). on Andoid…
28
votes
3 answers

How can I avoid blinking notification update while changing button

I have a Notification, which supports play,pause forward and back. private static Notification createNotification(String interpret, String title, boolean paused) { // if (builder == null) builder = new NotificationCompat.Builder(context); …
Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
28
votes
1 answer

Notification created by IntentService uses always a wrong Intent

Problem When the user presses Send "Button 1"(scroll down to see the construction of the app) a new Notification is created from the RefreshService. If the user presses this notification a MainActivity instance gets started and receives a String…
27
votes
2 answers

Android 8 notifications setSound not working

I have the following code but everytime I just hear the default android sound. // create channel NotificationChannel channel = new NotificationChannel(ANDROID_CHANNEL_ID, ANDROID_CHANNEL_NAME,…
Ricardo
  • 7,921
  • 14
  • 64
  • 111
27
votes
3 answers

Oreo - Foreground service does not show foreground notification

So far, I've adjsuted my code to use ContextCompat.startForegroundService(context, intentService); to start my service. This way, it works on android < 26 and on android 26 (Oreo) as well. I still see a difference, in android oreo I don't see my…
prom85
  • 16,896
  • 17
  • 122
  • 242
27
votes
6 answers

Firebase Notification Always shows blank icon

I'm new with FCM. I cannot make FCM use my app icon as notification icon and the icon is always a white blank one. I imported an icon to mipmap folders but nothing seems changed. As some dude say that this is because of lollipop notification as in…
26
votes
3 answers

Large notification icon background

Since Android 5.0 large icons in notifications have color background: For small icon, it is the accent color of notification (Notification.Builder.setColor(int)). How do I set it for large icon? Is it part of the actual image? If it is, what should…
Andrii Chernenko
  • 9,873
  • 7
  • 71
  • 89
25
votes
1 answer

java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.lang.Iterable.iterator()' when starting a notification

I noticed some of my users are getting this exception. I don't know how to reproduce it, I only have the reports on Crashlytics. Seems to be deep inside Google's code. Out of thousands who have used this code only 39 have had the exception. Any…
casolorz
  • 8,486
  • 19
  • 93
  • 200
25
votes
9 answers

Android - Clear task flag not working for PendingIntent

I have a task stack of A > B > C. I am currently on C, and then I press the home button. I get a notification with the intent to take me to Activity A. I press the notification, and I'm at A but if I press back, I go to C, then B, then A. I am…
user2676468
24
votes
9 answers

NotificationListenerService Implementation

I am trying to implement NotificationListnerService which is added in android 4.3 but I am not able to get the notification details. My code are as below public class MainActivity extends Activity { @Override protected void onCreate(Bundle…
Naga
  • 1,931
  • 4
  • 25
  • 42
23
votes
3 answers

Custom notification sound , android Oreo?

I want to set a custom notification sound from a raw mp3 or wav file in my app. Below is my code private void sendMyNotification(String message) { Intent intent; if (sharedPreferences.getBoolean(SPConstants.IS_LOGGED_IN, false)) { …
WISHY
  • 11,067
  • 25
  • 105
  • 197