Flo*_*her 10 notifications android push-notification android-notifications
什么向后兼容性
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
Run Code Online (Sandbox Code Playgroud)
提供我从正常情况下得不到的
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Run Code Online (Sandbox Code Playgroud)
他们都有一种notify
方法可以在我测试的设备上运行(低至API级别19).
此处的Google示例甚至不使用该Compat
版本一次:
从查看 的源代码来看NotificationManagerCompat
,大部分好处与取消通知和确定是否在 API 19 及更低版本上启用通知有关。特别是关于notify(),NotificationManagerCompat
可以在较旧的Android API级别上利用侧通道通知。这允许您注册一个NotificationCompatSideChannelService
,您可以使用它在这些旧的 Android API 上提供更强大的分组功能。