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

Can NoticationManager.notify() be called from a worker thread?

My question is more about what is a good practice than what is possible: Is it a good thing to call NoticationManager.notify() from a worker thread? Does the system execute it in the UI thread anyway or not? I always try to keep in mind that stuff…
Joffrey
  • 13,071
  • 1
  • 42
  • 68
46
votes
16 answers

Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

I am trying to post a notification with a custom view in the notification area from an IntentService, and getting the Couldn't expand RemoteView error. Here's what I am doing in onCreate(): mNotificationManager = (NotificationManager)…
Chaitanya
  • 2,009
  • 4
  • 25
  • 31
45
votes
2 answers

Honeycomb notifications - How to set largeIcon to the right size?

I find myself curious why the setLargeIcon method on Notification.Builder only accepts a Bitmap, with no overload to provide a resource id. Perhaps it was done for performance reasons, but it seems odd as setSmallIcon does accept a res drawable…
Ollie C
  • 27,184
  • 33
  • 125
  • 211
43
votes
5 answers

Is possible set Expanded Notification as default in Big Text Notifications?

I followed this Sample Code In Big Text Notifications section, he said that need expand to see Big text notification form, as image im below : I wonder that we can not set Expanded Notification as default in Big Text Notifications? People who know…
Huy Tower
  • 7,162
  • 13
  • 49
  • 81
43
votes
2 answers

Do GCM registration id's expire?

I know that C2DM registrations expire, and you are supposed to periodically refresh the registration ID. Is this the case with GCM? by looking at the following code on the Android GCM guide (shown below), it seems like you only do it once and don't…
Mohamed Hafez
  • 8,151
  • 6
  • 38
  • 49
42
votes
6 answers

Why do we use the TaskStackBuilder?

Why do we use the TaskStackBuilder when creating a notification? I do not get the logic behind it. Can someone please explain. public void showText(final String text){ Intent intent = new Intent (this, MainActivity.class); TaskStackBuilder…
MisterNowhere
  • 505
  • 1
  • 4
  • 13
42
votes
4 answers

How to update Notification with RemoteViews?

I'm creating a notification with RemoteViews from a custom Service, which is running with notification in a foreground mode (that is, service will remain active as long as notification is visible to user). Notification is set as Ongoing so user…
Sinisa
  • 2,628
  • 4
  • 22
  • 34
41
votes
5 answers

How To give notifications on android on specific time?

I want to give notification to my app on a specific time. Say everyday i have to give notification on 7 AM even if the app is closed. How can i do this? Any tutorial? Please mention the link.
admin 7798
  • 587
  • 1
  • 5
  • 12
40
votes
4 answers

On Android 8.1 API 27 notification does not display

I get Toast on Android 8.1 API 27: Developer warning for package "my_package_name" Failed to post notification on ... Logcat includes next strings: Notification: Use of stream types is deprecated for operations other than volume control …
40
votes
8 answers

Failed to post notification on channel "null" Target Api is 26

Two log showing 1: Use of stream types is deprecated for operations other than volume control 2: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
Mohit Singh
  • 1,211
  • 1
  • 8
  • 17
39
votes
2 answers

How to Schedule Notification in Android

I'm trying to set notification for a time in the future. I have the code for creating a notification but I can't find an option to schedule it. How can I schedule notifications?
OmerN
  • 843
  • 2
  • 9
  • 18
38
votes
6 answers

How to check if my app is allowed to show notification

In Android settings users can turn off notification if they don't want to. So is there any method that like isNotificationAllowed() to check is my app is allowed to show notification? And how to open android setting page to guide my users to turn on…
Yunpeng Lee
  • 405
  • 1
  • 4
  • 6
37
votes
5 answers

Flutter: Push notifications even if the app is closed

I have built an application with flutter that works like a reminder. How can I display notifications to the user even though the app is closed?
37
votes
3 answers

Push notification works incorrectly when app is on background or not running

I am using Firebase Cloud Messaging to send push notifications. Here is my FirebaseMessageService: public class FireBaseMessageService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { …
37
votes
3 answers

How to set the app icon as the notification icon in the notification drawer

As shown in the figure... I am getting my notification icon(on left to the red colour). But I need to display the app icon as shown by the black arrow public void notify(View view){ notification.setSmallIcon(R.drawable.ic_stat_name); …