Notification

extends Object
implements Parcelable

java.lang.Object


android.app.Notification

Public Constructors:   比较常用的构造方法

Notification(int icon, CharSequence tickerText, long when)

Constructs a Notification object with the information needed to have a status bar icon without the standard expanded view.

Public Methods

void setLatestEventInfo(

Context context,

CharSequence contentTitle,

CharSequence contentText,

PendingIntent contentIntent)

Sets the contentView field to be a view with the standard "Latest Event" layout.

Creating a Notification

int icon = R.drawable.notification_icon;        // icon from resources
CharSequence tickerText = "Hello";              // ticker-text
long when = System.currentTimeMillis();         // notification time
Context context = getApplicationContext();      // application Context
CharSequence contentTitle = "My notification";  // expanded message title
CharSequence contentText = "Hello World!";      // expanded message text

Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);// the next two lines initialize the Notification, using the configurations above
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

转载于:https://www.cnblogs.com/plant/p/4730551.html

Android Train—notification通知相关推荐

  1. android之Notification通知

    我们在用手机的时候,如果来了短信,而我们没有点击查看的话,是不是在手机的最上边的状态栏里有一个短信的小图标提示啊?你是不是也想实现这种功能呢?今天的Notification就是解决这个问题的. pac ...

  2. Android的notification通知

    概括: Android使用notification实现消息提醒,提供通知栏和通知抽屉查看通知和通知详情,Android的notification机制应用非常广泛,是指在应用程序之外显示的消息,布局由系 ...

  3. Android中notification通知的Demo——震动,铃声,Led灯闪烁

    这里要注意几点: 1. notification的各种方法及参数的应用 2. 旧版本的SDK和新版本的SDK消息推送的写法是有些不一样的   1. notification的各种方法及参数的应用  ( ...

  4. 四十一、Android Notification通知详解

    根据activity的生命周期,在activity不显示时,会执行onStop函数(比如按下home键),所以你在onStop函数(按退出键除外)里面把notification放在通知栏里,再此显示时 ...

  5. Android Notification通知详解

    Android Notification通知详解 Notification: (一).简介: 显示在手机状态栏的通知.Notification所代表的是一种具有全局效果的通知,程序一般通过Notifi ...

  6. Android篇 --Notification(消息通知)

    Android篇 --Notification(消息通知) 消息通知(Notification)是Android系统中比较有特色的一个功能,当某个应用程序希望用户发出一些提示信息,而该应用又不在前台运 ...

  7. Android Notification通知详细解释

    Android Notification通知具体解释 Notification: (一).简单介绍: 显示在手机状态栏的通知. Notification所代表的是一种具有全局效果的通知,程序一般通过N ...

  8. Android学习|控件——Notification通知

    Android学习|控件--Notification通知 一.前提 二.两个对象的的构建 1.创建NotificationManager 2.使用Builder构造器来创建Notification 2 ...

  9. Android学习日记 Notification 通知

    Android学习日记 Notification 通知 文章目录 Android学习日记 Notification 通知 前言 使用步骤 总结 前言 下拉状态栏显示的通知功能 使用步骤 代码如下: p ...

最新文章

  1. javascript——Array类型
  2. mysql高可用_mysql高可用方案
  3. mongodb 监控项详解(mms)
  4. nginx 上传文件漏洞_nginx爆惊天漏洞 上传图片就能入侵服务器
  5. centos7.9使用ssh命令进行登陆云服务器
  6. linux系统 qt调试,Linux下Qt Creator远程调试(redhat5+mini6410)
  7. 数据科学和统计学_数据科学中的统计
  8. linux 文件 重命名 缓存,linux – rename()原子性和NFS?
  9. python数据结构简单总结
  10. Mina网络通信框架
  11. 自学python能找到工作吗-通过自学python能找到工作吗
  12. 使用UE去除复制文本中的空格、换行符和TAB
  13. 一起来当网管(一)——Windows Server上的DHCP配置
  14. hustoj Runtime Error (运行错误)的解决方法
  15. 车牌识别用php算法,车牌识别算法实现及其代码实现之一:车牌区域检测
  16. python短期电力预测——基于LSTM神经网络
  17. 美颜SDK更换发色、染发功能实现流程
  18. 在微信群如何使用接龙功能
  19. c语言 最长单词,c语言求最长公共单词
  20. 华为IT总监离职时给大家写了一封告别信(ZT)

热门文章

  1. 微软2017校招笔试题3 registration day
  2. gdalwarp:变形工具
  3. 项目管理系统Redmine安装
  4. android java.net.ConnectException: Connection 127.0.0.1:8080 refused
  5. 日常护理常识以及化妆品的选购 - 健康程序员,至尚生活!
  6. Bootstrap初步
  7. scratch绘制多边形_如何使用Scratch 3绘制矢量图形
  8. opensource项目_Best of Opensource.com 2017:排名前27的文章和资源
  9. 南亚三大半岛_南亚最大的维基百科聚会开始
  10. CSS 盒倒影 box-reflect属性