美文网首页
Android学习整理 -11- 关于Notification的

Android学习整理 -11- 关于Notification的

作者: minminaya | 来源:发表于2017-03-20 13:54 被阅读142次

全面了解Android Notification


一个博主画的思维导图

出自Android Notification 详解

Android Notification.png

一些基本属性

public Builder setTicker(CharSequence tickerText)
设置状态栏开始动画的文字

public Builder setContentTitle(CharSequence title)
设置内容区的标题,必须设置

public Builder setContentText(CharSequence text)
设置内容区的内容,必须设置

public Builder setContentIntent(PendingIntent intent)
设置点击通知后操作(可以跳转Activity,打开Service,或者发送广播)

public Builder setColor(@ColorInt int argb)
这个可以设置smallIcon的背景色

public Builder setSmallIcon(@DrawableRes int icon)
设置小图标,必须设置

public Builder setLargeIcon(Bitmap b) 
设置打开通知栏后的大图标

public Builder setWhen(long when) 
设置显示通知的时间,不设置默认获取系统时间,这个值会在Notification上面显示出来

public Builder setAutoCancel(boolean autoCancel) 
设置为true,点击该条通知会自动删除,false时只能通过滑动来删除

public Builder setPriority(int pri)
设置优先级,级别高的排在前面

public Builder setDefaults(int defaults)
设置上述铃声,振动,闪烁用|分隔,常量在Notification里

public Builder setOngoing(boolean ongoing)
设置是否为一个正在进行中的通知,这一类型的通知将无法删除

注意

魅族手机,小米,华为自身带了要去通知栏管理打开权限,包括锁屏通知


酷狗的通知栏

建设中

相关文章

网友评论

      本文标题:Android学习整理 -11- 关于Notification的

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