Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 help to push the notification to Lock Screen ?

like image 330
MBH Avatar asked Oct 19 '15 08:10

MBH


People also ask

What is NotificationCompat builder?

public class NotificationCompat.Builder. Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts. On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.

How do you extend notifications?

To expand a notification, tap the Down arrow . Then, to act directly from a notification, tap an action, like Reply or Archive. Some apps show a dot when you get a notification. Touch and hold the app with the dot to see the oldest notification.


1 Answers

Note that v7 NotificationCompat was deprecated in API level 26, and that v4 was expanded a bit. If your compileSdk is 26+, you must use v4.


As you can see in the docs, v7 inherits from v4 and then adds some more functionality.

android.support.v7.app.NotificationCompat

An extension of NotificationCompat which supports NotificationCompat.MediaStyle. You should start using this variant if you need support for media styled notifications.

v7 can do everything v4 can. The only difference is that v7 also supports .MediaStyle, while v4 does not.

Regarding lock screen, there are some constants that define how they work, e.g. if they are shown or not:

VISIBILITY_PRIVATE, VISIBILITY_PUBLIC and VISIBILITY_SECRET

like image 81
Tim Avatar answered Oct 14 '22 03:10

Tim