美文网首页
RemoteViews之Notification

RemoteViews之Notification

作者: 边走边玩FREE | 来源:发表于2018-11-30 11:54 被阅读0次

创建 Notification
Notification 的创建主要涉及到 Notification.Builder 、 Notification 、 NotificationManager 。

Notification 三种创建方式:

  1. new Notification() : Android 3.0 之前的版本 使用,后面版本不兼容。

2.Notification.Builder :使用建造者模式构建 Notification 对象,但 Notification.Builder 仅支持 Android 4.1及之后的版本

  1. NotificationCompat.Builder :在 Android Support v4包中加入,用来兼容不同版本,目前使用最多的的就在该形式,避免不同平台兼容问题。

NotificationManager

NotificationManager 是通知管理类,它是一个系统服务。调用 NotificationManager 的 notify() 方法可以向系统发送通知。

获取 NotificationManager 对象

NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

相关文章

网友评论

      本文标题:RemoteViews之Notification

      本文链接:https://www.haomeiwen.com/subject/mzgccqtx.html