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; /////第三步:啟動(dòng)通知欄,第一個(gè)參數(shù)是一個(gè)通知的唯一標(biāo)識(shí) nm.notify(0, notification); //關(guān)閉通知 //nm.cancel(0);
您可能感興趣的文章:
- Android中通知Notification使用實(shí)例(振動(dòng)、燈光、聲音)
- Android中通過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 string-array數(shù)據(jù)源簡單使用
這篇文章主要介紹了Android string-array數(shù)據(jù)源簡單使用的相關(guān)資料,需要的朋友可以參考下2016-09-09Android自定義View實(shí)現(xiàn)打字機(jī)效果
最近在做Android開發(fā)的時(shí)候,需要做類似于打字機(jī)打字的效果,字一個(gè)一個(gè)地蹦出來,顯示每一個(gè)字都帶有打字的聲音?,F(xiàn)在分享給大家,有需要的可以參考借鑒。2016-08-08Android編程實(shí)現(xiàn)ListView內(nèi)容無限循環(huán)顯示的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)ListView內(nèi)容無限循環(huán)顯示的方法,通過繼承Adapter類實(shí)現(xiàn)ListView中的數(shù)據(jù)無限循環(huán)顯示功能,需要的朋友可以參考下2017-06-06Android Jetpack導(dǎo)航組件Navigation創(chuàng)建使用詳解
這篇文章主要為大家介紹了Android Jetpack導(dǎo)航組件Navigation創(chuàng)建及使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11android實(shí)現(xiàn)Uri獲取真實(shí)路徑轉(zhuǎn)換成File的方法
這篇文章主要介紹了android實(shí)現(xiàn)Uri獲取真實(shí)路徑轉(zhuǎn)換成File的方法,涉及Android操作路徑的相關(guān)技巧,需要的朋友可以參考下2015-05-05Android自定義漸變式炫酷ListView下拉刷新動(dòng)畫
這篇文章主要為大家詳細(xì)介紹了Android自定義漸變式炫酷ListView下拉刷新動(dòng)畫,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02