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
32
votes
5 answers

Open specific Activity when notification clicked in FCM

I am working on App in which I am required to show notification. For notification, i am using FireBase Cloud Messaging (FCM). I am able to get Notification when app is in background. But when I click on notification, it redirect to home.java page.…
32
votes
2 answers

PendingIntent not opening Activity in Android 4.3

In my Service, I open up a notification on normal run, using this code: private final static NOTIFICATION_ID = 412434; private void startNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder( this); …
Lanbo
  • 15,118
  • 16
  • 70
  • 147
32
votes
2 answers

How to properly clear all notification once clicked?

I send a few notification on the notification bar, i wanted to clear all of it when one of the notification is clicked. For now I clear one by one by using Flag. I know notificationManager.cancelAll() could clear all the notification but where…
Eric
  • 1,547
  • 2
  • 18
  • 34
31
votes
7 answers

Clicking on Notification is not starting intended activity?

I am using GCM in my application and also using NotificationManager to Create a Notification whenever GCM message is received.Till now everything is working perfectly and GCM message is showing correctly in Notification area, but when I click on the…
Ansh
  • 2,366
  • 3
  • 31
  • 51
31
votes
2 answers

How to implement the deprecated methods of Notification

I have a small problem but dont understand how to get out of this. I created a class for providing Notifications, but these lines are marked deprecated: ... Notification notification = new Notification(icon, text, time); // deprecated in API level…
Chintan Soni
  • 24,761
  • 25
  • 106
  • 174
31
votes
1 answer

How to use Actions from Notification without starting Activity

So I'm working on a simple music player. The music player as it names states, can play a song, pause playback, forward to next song, go back to previous song, and stop playback completely. When you play a song, there will be a notification displayed…
30
votes
3 answers

NotificationCompat.Builder setLargeIcon() not working?

When I add the code mNotificationBuilder.setLargeIcon(BitmapFactory.decodeResource( getResources(), R.drawable.ic_large_icon)); to my notification it stops working without errors or warnings. This only happens on pre-Lollipop, on Lollipop and beyond…
30
votes
1 answer

what is the difference between v4.app.NotificationCompat and v7.app.NotificationCompat?

I was reading a tutorial on google official website for building Notification While implementing the code I noticed that NotificationCompat is existed in both Support Libraries V4 and V7. what is the difference between them though? Does any of them…
MBH
  • 16,271
  • 19
  • 99
  • 149
29
votes
8 answers

Changing LED color for notifications

I am basically just experimenting with Android development, and a couple of days ago I came across this app called "Go SMS Pro", which, among other things, can set up notifications in different colors (blue, green, orange, pink and light blue). So,…
Frxstrem
  • 38,761
  • 9
  • 79
  • 119
29
votes
3 answers

Notification.Builder(context) deprecated Android O

Notification.Builder(context) has been deprecated recently with the venue of Notification Channels in Android O. PROBLEM: After using Notification.Builder(context, StringID) instead of Notification.Builder(context)I did receive a notification to…
Red M
  • 2,609
  • 3
  • 30
  • 50
29
votes
5 answers

Get value from RemoteMessage from FCM onMessageReceived method

I have migrate gcm to fcm for push notification message. but how I Get bundle data from RemoteMessage received onMesssageReceived method. Old GCM give bundle data onMessageReceiced method but in FCM there is RemoteMessage data. So please tell me…
29
votes
3 answers

Full Screen Notification only showing as a Heads Up

I have been banging my head against the table with this problem for 3 days now, please tell me where I have strayed. When I am getting an incoming VoIP call, I am trying to show a full screen notification, just like the PhoneApp does. I am ok with…
Leo
  • 4,652
  • 6
  • 32
  • 42
29
votes
1 answer

Music player control in notification

how to set notification with play/pause, next and previous button in android.! I am new with Android & also at stack overflow. So please bear with me. I set notification when song is start to play like below : ` @SuppressLint("NewApi") public void…
29
votes
6 answers

How to cancel a foreground service from using the notification (swipe dismiss) or clear all notifications?

I'm currently creating a foreground service with a notification that appears in the notification bar when the service starts. If the service stops, the notification dismisses. My question is, is there a way to stop the service when "clear all…
d.moncada
  • 16,900
  • 5
  • 53
  • 82
28
votes
3 answers

Why did Android 13 remove the Foreground Service notification?

Sorry for the sort of click-bait title; I couldn't think of a more concise way to say it. In Android 13, if the user doesn't grant the "dangerous" POST_NOTIFICATION permission, then Foreground Service notifications are not shown in the Notification…
user19309143