NotificationManager(通知管理器):
NotificationManager负责通知用户事件的发生.
NotificationManager有三个公共方法:
1. cancel(int id) 取消以前显示的一个通知.假如是一个短暂的通知,试图将隐藏,假如是一个持久的通知,将从状态条中移走.
2. cancelAll() 取消以前显示的所有通知.
3. notify(int id, Notification notification) 把通知持久的发送到状态条上.
- //初始化NotificationManager:
- NotificationManager nm =
- (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification代表着一个通知.
Notification的属性:
audioStreamType 当声音响起时,所用的音频流的类型
contentIntent 当通知条目被点击,就执行这个被设置的Intent.
contentView 当通知被显示在状态条上的时候,同时这个被设置的视图被显示.
defaults 指定哪个值要被设置成默认的.
deleteIntent 当用户点击"Clear All Notifications"按钮区删除所有的通知的时候,这个被设置的Intent被执行.
icon 状态条所用的图片.
iconLevel 假如状态条的图片有几个级别,就设置这里.
ledARGB LED灯的颜色.
ledOffMS LED关闭时的闪光时间(以毫秒计算)
ledOnMS LED开始时的闪光时间(以毫秒计算)
number 这个通知代表事件的号码
sound 通知的声音
tickerText 通知被显示在状态条时,所显示的信息
vibrate 振动模式.
when 通知的时间戳.
Notification的公共方法:
describeContents() Describe the kinds of special objects contained in this Parcelable's marshalled representation.
setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) 设置Notification留言条的参数
writeToParcel(Parcel parcel, int flags) Flatten this notification from a parcel.
toString() …………….
将Notification发送到状态条上:
- Notification notification = new Notification();
- Notification的设置过程……..
- nm.notify(0, notification); //发送到状态条上
分享到:
相关推荐
android 状态栏的图标与文字提醒 NotificationManager与Notification
首先,发送一个状态栏通知必须用到两个类:NotificationManager、Notification。 NotificationManager:是状态栏通知的管理类,负责发通知、清楚通知等。 NotificationManager是一个系统Service,必须通过...
调用getSystemService(NOTIFICATION_SERVICE)方法获取系统的NotifacationManager服务 通过构造器创建一个Notification对象 为Notification设置各种属性 通过NotificationManager发送Notification。
首先,发送一个状态栏通知必须用到两个类: NotificationManager 、 Notification。 NotificationManager : 是状态栏通知的管理类,负责发通知、清楚通知等。 NotificationManager 是一个系统Service,必须通过 ...
自学 Android 做的第二十七个 Android 程序,使用了 NotificationManager、Notification 和 Notification.Builder
NULL 博文链接:https://forlan.iteye.com/blog/2264722
这个例子演示Android 在状态栏... NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, myNotification);//发送Notification
本文主要讲解状态栏通知Notification、NotificationManager,小编觉得非常详细,给大家一个参考,希望对大家学习有所帮助。
NULL 博文链接:https://hualikejava.iteye.com/blog/953947
本文实例讲解了通知Notification使用方法,此知识点就是用作通知的显示,包括振动、灯光、声音等效果,分享给大家供大家参考,具体内容如下 效果图: MainActivity: import java.io.File; import android....
可以设置一条通知,当然可以更新一条通知,我们通过在调用NotificationManager.notify(ID, notification)时所使用的ID来更新它。为了更新你之前发布的通知,你需要更新或者创建一个NotificationCompat.Builder对象,...
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, notification); or Json2Notification.from(context)....
在使用手机时,当有未接来电或者新短消息时,手机会给...使用Notification和NotificationManager类发送和显示通知也比较简单,大致可以分为以下四个步骤 (1)调用getSystemService() 方法获取系统的NotificationManag
要使用消息通知,必须要用到两个类:NotificationManager和Notification,其他NotificationManager的初始化是用getSystemService方法,并且通过notify方法来向android系统发送消息栏通知和显示。效果 :代码: 代码...
在使用手机时,当有未接来电或者是新短消息时,手机会给出...使用Notification和NotificationManager类发送和显示通知也比较简单,大致可分为以下4个步骤。 (1)调用getSystemService()方法获取系统的NotificationManag
notification类表示一个持久的通知,将提交给用户使用NotificationManager。已添加的Notification.Builder,使其更容易构建通知。
这个自动检测升级Apk的功能,相信每个应用都会使用到。...其中使用Service、BroadcastReceiver、OkHttp下载、Gson解析json、NotificationManager、Notification 运用的知识也挺多的,也可以功大家学习使用。
关于通知Notification相信大家都不陌生了,平时上QQ的时候有消息来了或者有收到了短信,手机顶部就会显示有新消息什么的,就类似这种。今天就稍微记录下几种Notification的用法。3.0以前的通知和3.0以后的通知是有些...
主要介绍了Android 使用AlarmManager和NotificationManager来实现闹钟和通知栏,需要的朋友可以参考下