NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);Notification notification = new Notification(android.R.drawable.btn_default, "新的通知", System.currentTimeMillis());     // 通过构造函数设定通知的图标与标题Intent intentNoti = new Intent(Intent.ACTION_VIEW);    // 可以使用其他的意图,以实现希望的功能PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intentNoti, 0);notification.setLatestEventInfo(getApplicationContext(), "通知的标题", "通知的内容", contentIntent);    // 设定通知的标题与内容,超出一行的部分将被省略notificationManager.notify(notificationID, notification);   // 生成 ID 为 notificationID 的通知。若该 ID 已存在,则更新已有通知的内容

说明:NotificationManager 可以通过 getSystemService(NOTIFICATION_SERVICE) 方法取得。它本身还有一些其他的便利方法:cancel(int id)删除指定 id 的通知。cancelAll()删除本应用程序发出的所有通知。

更多相关文章

  1. Android(安卓)5.1 SystemUI-状态栏
  2. android之File
  3. android 取消标题,程序意外停止
  4. Android(安卓)调用系统的分享[完美实现同时分享图片和文字]
  5. NFS挂载android文件系统
  6. 关于Android(安卓)混淆的内容总结
  7. android中文api (59) —— TabHost.TabSpec
  8. android 读取文件内容操作
  9. Android(安卓)Fresco图片处理库用法API英文原文文档2-1(Facebook

随机推荐

  1. Visual Studio 2015正式发布
  2. Android实现Rxjava2+Retrofit完美封装
  3. Android学习手记(2) Activity生命周期
  4. 【Android】 onClick与onTouch并存触发的
  5. Project interpreter not specified(ecli
  6. android和ios GoogleMap画导航线路图 路
  7. Android(安卓)创世纪 第一天
  8. 用x86的模拟器内核记得安装intel的haxm
  9. android 获取手机内存大小
  10. android 之 Androidpn 消息推送总结