Since Jelly Bean it is possible to set a priority to notifications. This way you can even set PRIORITY_MIN which will hide the notification icon on status bar.
I read about it and it is very simple, you just have to use this:
MyNotification.setPriority(Notification.PRIORITY_MIN);
My problem es that I get the compile error:
“The method setPriority (int) is undefined for the type Notification”
My application has to run in different versions of Android, so, I understand that function is not available under JellyBean, so is there a way to include compiler tags or something similar to add that functionality depending on the Android release.
I hope you understand what I mean.
Android will handle this automagically. No need for additional markup for specific version numbers. When it comes to your compile error, I’ve had luck with something like my code below. You want to make sure to use
NotificationCompatand make sure you importandroid.support.v4.app.NotificationCompat;as well.This code should work: