Changing notification icon background on Lollipop

1) Obtain Color int color = 0xff123456; int color = getResources().getColor(R.color.my_notif_color); int color = ContextCompat.getColor(context, R.color.my_notif_color); 2) Set the Color to the Notification NotificationCompat.Builder builder = new NotificationCompat.Builder(this); … builder.setColor(color); Notification notif = builder.build(); The color is respected only on Lollipop and only affects background of the small icon. If a large icon is shown … Read more

Custom notification layouts and text colors

The solution is to use built-in styles. The style you need is called TextAppearance.StatusBar.EventContent in Android 2.3 and Android 4.x. In Android 5.x material notifications use several other styles: TextAppearance.Material.Notification, TextAppearance.Material.Notification.Title, and TextAppearance.Material.Notification.Line2. Just set the appropriate text appearance for the text view, and you will get the necessary colors. If you are interested how … Read more

How to remove notification from notification bar programmatically in android?

Maybe try this : NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); OR, you can also do this to cancel all notifications in given context: notificationManager.cancelAll(); See this link to the documentation : NotificationManager

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

You can’t 100% can’t. It is asked in this Google I/O 2012 video and the Project lead for the new notifications declares that you can’t. Edit 2016 update: Now you can check it, as said in this Google I/O 2016 video. Use NotificationManagerCompat.areNotificationsEnabled(), from support library, to check if notifications are blocked on API 19+. … Read more

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

The following will work in Android 5.0 (Lollipop) and above: Intent intent = new Intent(); intent.setAction(“android.settings.APP_NOTIFICATION_SETTINGS”); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //for Android 5-7 intent.putExtra(“app_package”, getPackageName()); intent.putExtra(“app_uid”, getApplicationInfo().uid); // for Android 8 and above intent.putExtra(“android.provider.extra.APP_PACKAGE”, getPackageName()); startActivity(intent); Notes: This is not officially supported in Android 5-7, but it works just fine. It IS officially supported as of Android 8. … Read more

Notification passes old Intent Extras

You are sending the same request code for your pending intens. Change this: PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); To: PendingIntent contentIntent = PendingIntent.getActivity(context, UNIQUE_INT_PER_CALL, notificationIntent, 0); intents are not created if you send the same params. They are reused.

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

What was happening was, I was including the integer reference to the icon in the PendingIntent bundle, and that integer was later being referenced while being posted to the NotificationManager. In between getting the integer reference and the pending intent going off, the app was updated and all of the drawable references changed. The integer … Read more