android中創(chuàng)建通知欄Notification代碼實例
更新時間:2015年05月20日 09:50:32 投稿:junjie
這篇文章主要介紹了android中創(chuàng)建通知欄Notification代碼實例,本文直接給出實現(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; /////第三步:啟動通知欄,第一個參數(shù)是一個通知的唯一標識 nm.notify(0, notification); //關閉通知 //nm.cancel(0);
您可能感興趣的文章:
- Android中通知Notification使用實例(振動、燈光、聲音)
- Android中通過Notification&NotificationManager實現(xiàn)消息通知
- android使用NotificationListenerService監(jiān)聽通知欄消息
- Android 中Notification彈出通知實現(xiàn)代碼
- Android開發(fā) -- 狀態(tài)欄通知Notification、NotificationManager詳解
- Android 通知使用權(NotificationListenerService)的使用
- Android使用Notification在狀態(tài)欄上顯示通知
- Android中AlarmManager+Notification實現(xiàn)定時通知提醒功能
- Android種使用Notification實現(xiàn)通知管理以及自定義通知欄實例(示例四)
- Android使用Notification實現(xiàn)通知功能
相關文章
Android string-array數(shù)據(jù)源簡單使用
這篇文章主要介紹了Android string-array數(shù)據(jù)源簡單使用的相關資料,需要的朋友可以參考下2016-09-09Android編程實現(xiàn)ListView內容無限循環(huán)顯示的方法
這篇文章主要介紹了Android編程實現(xiàn)ListView內容無限循環(huán)顯示的方法,通過繼承Adapter類實現(xiàn)ListView中的數(shù)據(jù)無限循環(huán)顯示功能,需要的朋友可以參考下2017-06-06Android Jetpack導航組件Navigation創(chuàng)建使用詳解
這篇文章主要為大家介紹了Android Jetpack導航組件Navigation創(chuàng)建及使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11android實現(xiàn)Uri獲取真實路徑轉換成File的方法
這篇文章主要介紹了android實現(xiàn)Uri獲取真實路徑轉換成File的方法,涉及Android操作路徑的相關技巧,需要的朋友可以參考下2015-05-05