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
23
votes
1 answer

Single Notification for multiple Foreground Services using startForeground() call

I have an app that has two services. One is for showing UI for floating (overlay) on other apps using WindowManager. The other is for Location Tracking using GooglePlayAPI. My app always runs these services. I want these services not to be killed by…
Peter Han
  • 231
  • 1
  • 2
  • 3
23
votes
6 answers

Android notification is not showing it's content when app is not running

Here is my interesting problem. Android notification that comes from GCM is not showing title and content (just shows App Name, and when click, open the MainActivity) when app is not running. But when the app is open, it's showing successfully…
Ozgur
  • 3,738
  • 17
  • 34
23
votes
2 answers

Create Custom Big Notifications

I wanted to create a Notification including some controls. Since text and controls are small with default notification size (64dp), i wanted have it larger than default size. It is possible to create larger notifications, and I think it is possible…
MalaKa
  • 3,734
  • 2
  • 18
  • 31
22
votes
1 answer

Icon is not getting displayed in notification in Android nougat

I researched about this and found out that addAction (int icon, CharSequence title, PendingIntent intent) is deprecated, so I used addAction (Notification.Action action) . In both the cases, icon cant be seen. NotificationCompat.Action action = new…
MrRobot9
  • 2,402
  • 4
  • 31
  • 68
22
votes
0 answers

NotificationListenerService onNotificationPosted() called multiple times for single Notification when it is part of grouped notification

I am trying to listen to android notification using NotificationListenerService. I have tested the code with Whatsapp and Hangout notifications. Scenario 1: 1 Message from 1 User I receive onNotificationPosted() call once (which is correct) Scenario…
Neha Dargad
  • 221
  • 1
  • 5
22
votes
3 answers

putExtra using pending intent not working

I have written a code in my GCMIntentservice that sends push notifications to many users. I use the NotificationManager that will call DescriptionActivity class when the notification is clicked. I also send the event_id form the GCMIntentService to…
21
votes
2 answers

Notification with "null" PendingIntent

I'm trying to implement notification in Android. Now I have a problem, I don't want to have a PendingIntent that user will open any Activity. How can I do that?
peterlawn
  • 2,371
  • 6
  • 25
  • 44
21
votes
3 answers

Lollipop Notification setVisibility() Does Not Work?

I am trying to write a demo of using setVisibility() to control what shows up on the Android 5.0 lockscreen for a Notification. However, there seems to be no effect: the default VISIBILITY_PRIVATE still shows the private Notification, not its…
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
21
votes
3 answers

How to get Ringtone name in Android?

I'm allowing my user to pick a ringtone for notifications in my app. I want to store the URI of the sound along with the human readable title of the sound. So far the URI code works great: Uri uri =…
c_idle
  • 1,448
  • 4
  • 22
  • 40
21
votes
5 answers

Android - use external profile image in notification bar like Facebook

I know you can send info in the push notification parameters like message, title, image URL, etc. How does Facebook show your profile pic with your message in the notification area? I want to use an external image in the notification area, so when…
21
votes
5 answers

Allow notification to be cancelled after calling stopForeground(false)

I have a Media service that uses startForeground() to show a notification when playback starts. It has pause/stop buttons when playing, play/stop buttons while paused. NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); //…
21
votes
2 answers

How to Create a Reminder Notification

I have referred many sites but still I am not able to create the notification(reminder or alarm) I don't know exactly how to create and work with it. Its to notify/remind user about task and also provide daily tips to the user.. I will be glad to…
Rushabh
  • 385
  • 2
  • 5
  • 14
20
votes
1 answer

Firebase Cloud Messaging + Android: Priority of silent notifications

TLDR: Messages send to Android devices via FCM take between 10 seconds and 5 minutes to get delivered. Probably due to priority. I set it to "high", but it seems like it doesn't stay on that value. I develop an app both for iOS and Android. My…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
20
votes
2 answers

How to send to "Miscellaneous" notification channel?

Problem description When I try to send a Notification in Android O I have to specify a NotificationChannel to send to. If I use the old method (not setting up any channel) like this NotificationCompat.Builder(this), the Notification will not be…
creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
20
votes
1 answer

Firebase notifications not working in Android Emulator

I am developing an Android app which uses Firebase to send notifications. Everything works as expected when using my physical device (Google Nexus 5, and also tested on others), but I cannot receive notification when using the emulator. Platform:…
peval27
  • 1,239
  • 2
  • 14
  • 40