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
267
votes
13 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
  • 13,357
  • 6
  • 39
  • 55
213
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?
193
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
  • 10,760
  • 10
  • 47
  • 69
189
votes
24 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:
186
votes
10 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,891
  • 3
  • 15
  • 33
178
votes
10 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,238
  • 3
  • 17
  • 20
168
votes
20 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,569
  • 17
  • 65
  • 96
152
votes
26 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 ) …
149
votes
7 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 =…
117
votes
12 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,621
  • 7
  • 41
  • 49
113
votes
19 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 Sarabu
  • 3,886
  • 8
  • 33
  • 66
103
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…
99
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…
97
votes
5 answers

How to remove notification from notification bar programmatically in android?

How can one remove a notification from an application programmatically, which is called using Pending intent? I have used to cancel notification using following method: AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent…
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,270
  • 3
  • 31
  • 37
1
2 3
99 100