一個(gè)博主畫的思維導(dǎo)圖
Android Notification.png
一些基本屬性
public Builder setTicker(CharSequence tickerText)
設(shè)置狀態(tài)欄開始動(dòng)畫的文字
public Builder setContentTitle(CharSequence title)
設(shè)置內(nèi)容區(qū)的標(biāo)題,必須設(shè)置
public Builder setContentText(CharSequence text)
設(shè)置內(nèi)容區(qū)的內(nèi)容抢韭,必須設(shè)置
public Builder setContentIntent(PendingIntent intent)
設(shè)置點(diǎn)擊通知后操作(可以跳轉(zhuǎn)Activity抡医,打開Service肥卡,或者發(fā)送廣播)
public Builder setColor(@ColorInt int argb)
這個(gè)可以設(shè)置smallIcon的背景色
public Builder setSmallIcon(@DrawableRes int icon)
設(shè)置小圖標(biāo)但校,必須設(shè)置
public Builder setLargeIcon(Bitmap b)
設(shè)置打開通知欄后的大圖標(biāo)
public Builder setWhen(long when)
設(shè)置顯示通知的時(shí)間炸茧,不設(shè)置默認(rèn)獲取系統(tǒng)時(shí)間二驰,這個(gè)值會(huì)在Notification上面顯示出來
public Builder setAutoCancel(boolean autoCancel)
設(shè)置為true扔罪,點(diǎn)擊該條通知會(huì)自動(dòng)刪除,false時(shí)只能通過滑動(dòng)來刪除
public Builder setPriority(int pri)
設(shè)置優(yōu)先級(jí)桶雀,級(jí)別高的排在前面
public Builder setDefaults(int defaults)
設(shè)置上述鈴聲矿酵,振動(dòng),閃爍用|分隔矗积,常量在Notification里
public Builder setOngoing(boolean ongoing)
設(shè)置是否為一個(gè)正在進(jìn)行中的通知全肮,這一類型的通知將無法刪除
注意
魅族手機(jī),小米棘捣,華為自身帶了要去通知欄管理打開權(quán)限辜腺,包括鎖屏通知
酷狗的通知欄
建設(shè)中