0

I've been trying to add notifications for my android app and I came across this StackOverflow question, which shows two ways to create a non clearable notification for different API levels.

I have used the older API style for creating the notification in my app and it works perfectly well but I was wondering if there are any issues with the older way or what benefits the newer API form offers?

Community
  • 1
  • 1

1 Answers1

1

The NotificationCompat approach provides a backward compatible API for supporting all API 4+ devices.

If you want to use big view styles (available on Android 4.1+ devices), this allows you to add those features automatically on Android 4.1+ devices without writing if checks around the API version.

It is also the only way of adding Wearable features to your notifications, including voice input, additional pages of information, or stacking notifications to provide additional information on wearables even when the phone is only showing a summary notification (using an InboxStyle for example).

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Ah right, i didn't even think of the big view notifications or wearables. I thought the NotificationCompat only worked with newer APIs so i thought the older style might have been beneficial for supporting older devices but as you said that isn't the case. Thanks a lot for you're help, I guess I'm better changing my code. –  Aug 31 '14 at 19:48
  • Yeah there's really no reason not to use the `NotificationCompat` classes rather than the built in defaults - any new APIs added to Android are also added to `NotificationCompat` as well which makes it much easier to support all API levels. – ianhanniballake Aug 31 '14 at 19:50
  • Yeah, it seems like the best way to go. Thanks again. –  Aug 31 '14 at 20:01