android中創(chuàng)建通知欄Notification代碼實(shí)例
更新時(shí)間:2015年05月20日 09:50:32 投稿:junjie
這篇文章主要介紹了android中創(chuàng)建通知欄Notification代碼實(shí)例,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
///// 第一步:獲取NotificationManager
NotificationManager nm = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
///// 第二步:定義Notification
Intent intent = new Intent(this, OtherActivity.class);
//PendingIntent是待執(zhí)行的Intent
PendingIntent pi = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
Notification notification = new Notification.Builder(this)
.setContentTitle("title")
.setContentText("text")
.setSmallIcon(R.drawable.ic_launcher).setContentIntent(pi)
.build();
notification.flags = Notification.FLAG_NO_CLEAR;
/////第三步:?jiǎn)?dòng)通知欄,第一個(gè)參數(shù)是一個(gè)通知的唯一標(biāo)識(shí)
nm.notify(0, notification);
//關(guān)閉通知
//nm.cancel(0);
您可能感興趣的文章:
- Android中通知Notification使用實(shí)例(振動(dòng)、燈光、聲音)
- Android中通過(guò)Notification&NotificationManager實(shí)現(xiàn)消息通知
- android使用NotificationListenerService監(jiān)聽通知欄消息
- Android 中Notification彈出通知實(shí)現(xiàn)代碼
- Android開發(fā) -- 狀態(tài)欄通知Notification、NotificationManager詳解
- Android 通知使用權(quán)(NotificationListenerService)的使用
- Android使用Notification在狀態(tài)欄上顯示通知
- Android中AlarmManager+Notification實(shí)現(xiàn)定時(shí)通知提醒功能
- Android種使用Notification實(shí)現(xiàn)通知管理以及自定義通知欄實(shí)例(示例四)
- Android使用Notification實(shí)現(xiàn)通知功能
相關(guān)文章
Android用代碼獲取手機(jī)root之后的最高權(quán)限
機(jī)得root之后通過(guò)代碼可以獲得最高權(quán)限如果沒有root的話請(qǐng)不要往下看,毫無(wú)意義,root之后的朋友可以參考下本文或許有意想不到的收獲2013-03-03
Android編程之頁(yè)面切換測(cè)試實(shí)例
這篇文章主要介紹了Android編程之頁(yè)面切換測(cè)試,實(shí)例分析了Android實(shí)現(xiàn)頁(yè)面點(diǎn)擊切換的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04
Android中關(guān)于自定義相機(jī)預(yù)覽界面拉伸問(wèn)題
這篇文章主要為大家詳細(xì)介紹了Android中關(guān)于自定義相機(jī)預(yù)覽界面拉伸問(wèn)題,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
Android復(fù)選框?qū)υ捒蛴梅▽?shí)例簡(jiǎn)析
這篇文章主要介紹了Android復(fù)選框?qū)υ捒蛴梅?結(jié)合實(shí)例形式簡(jiǎn)單分析了Android復(fù)選對(duì)話框的創(chuàng)建與使用技巧,需要的朋友可以參考下2016-01-01
Android使用緩存機(jī)制實(shí)現(xiàn)文件下載及異步請(qǐng)求圖片加三級(jí)緩存
這篇文章主要介紹了Android使用緩存機(jī)制實(shí)現(xiàn)文件下載及異步請(qǐng)求圖片加三級(jí)緩存的相關(guān)資料,需要的朋友可以參考下2016-02-02
Android使用fragment實(shí)現(xiàn)左側(cè)導(dǎo)航
這篇文章主要為大家詳細(xì)介紹了Android使用fragment實(shí)現(xiàn)左側(cè)導(dǎo)航,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-02-02
Android O實(shí)現(xiàn)Framework層CENTER鍵長(zhǎng)按功能方法
這篇文章主要為大家介紹了Android O實(shí)現(xiàn)Framework層CENTER鍵長(zhǎng)按功能方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08

