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

4666 questions
229
votes
10 answers

startForeground fail after upgrade to Android 8.1

After upgrading my phone to 8.1 Developer Preview my background service no longer starts up properly. In my long-running service I've implemented a startForeground method to start the ongoing notification which is called in on…
Rawa
  • 10,673
  • 6
  • 33
  • 52
211
votes
20 answers

Notification bar icon turns white in Android 5 Lollipop

I have an app showing custom notifications. The problem is that when running in Android 5 the small icon in the Notification bar is shown in white. How can I fix this?
190
votes
24 answers

Notification not showing in Oreo

Normal Notification Builder doesn't show notifications on Android O. How could I show notification on Android 8 Oreo? Is there any new piece of code to add for showing notification on Android O?
amorenew
  • 9,874
  • 8
  • 40
  • 64
183
votes
23 answers

INSTALL_FAILED_DUPLICATE_PERMISSION... C2D_MESSAGE

I am using Google notifications in my app, and until now I have done below in the manifest:
172
votes
9 answers

NotificationCompat.Builder deprecated in Android O

After upgrading my project to Android O buildToolsVersion "26.0.1" Lint in Android Studio is showing a deprecated warning for the follow notification builder method: new NotificationCompat.Builder(context) The problem is: Android Developers update…
GuilhermeFGL
  • 2,660
  • 2
  • 11
  • 31
160
votes
18 answers

Android Notification Sound

I've used the newer NotificationCompat builder and I can't get the notification to make a sound. It will vibrate and flash the light. The android documentation says to set a style which I've done with: builder.setStyle(new…
James MV
  • 8,145
  • 14
  • 61
  • 87
160
votes
9 answers

How to dismiss notification after action has been clicked

Since API level 16 (Jelly Bean), there is the possibility to add actions to a notification with builder.addAction(iconId, title, intent); But when I add an action to a notification and the action is pressed, the notification is not going to be…
endowzoner
  • 2,058
  • 3
  • 16
  • 20
143
votes
6 answers

Notification passes old Intent Extras

i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon =…
139
votes
23 answers

How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn't create icon: StatusBarIcon

I'm seeing the following exception in crash logs: android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn't create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 ) …
107
votes
18 answers

How to display multiple notifications in android

I am receiving only one notification and if there comes another notification, it replaces the previous one and here is my code private static void generateNotification(Context context, String message, String key) { int icon =…
Kartheek s
  • 3,737
  • 6
  • 28
  • 58
99
votes
6 answers

Android 4.1: How to check notifications are disabled for the application?

Android 4.1 offers the user a check box to disable notifications for a specific application. However, as a developer we have no way to know whether a call to notify was effective or not. I really need to check if the notifications are disabled for…
97
votes
4 answers

Android: Test Push Notification online (Google Cloud Messaging)

Update: GCM is deprecated, use FCM I am implementing Google Cloud Messaging in my application. Server code is not ready yet and in my environment due to some firewall restrictions I can not deploy a test sever for push notification. What I am…
93
votes
10 answers

Any way to link to the Android notification settings for my app?

Is there any way I can launch an intent to get to Android's notification settings screen for my app (pictured below)? Or an easy way I can make a PreferenceScreen item that just leads here on a click?
Mohamed Hafez
  • 8,151
  • 6
  • 38
  • 49
82
votes
12 answers

Custom notification layouts and text colors

My application shows some notifications, and depending on user preferences it might use a custom layout in a notification. It works well, but there is a small problem -- text colors. Stock Android and almost all manufacturer skins use black text…
Veeti
  • 5,149
  • 3
  • 29
  • 37
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 Boldizsár
  • 2,109
  • 2
  • 22
  • 32
1
2 3
99 100