private static final int NOTIFICATION_ID=250;  //用来标示notification,通过notificatinomanager来发布同样标示的notification将更新旧的通知,同时取消notification也需要这个标示(android很多地方都用到标示这么一个玩意)
  
private void setNotification(String note) {
     //获取系统通知服务
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.icon = R.drawable.notify; //通知图标,官方文档中说必须有icon才能显示出notification
notification.when = System.currentTimeMillis();
notification.tickerText = note; //通知出现在标题栏时显示的内容
notification.flags = Notification.FLAG_ONGOING_EVENT; // 设置常驻Flag
notification.defaults = Notification.DEFAULT_SOUND; //设置notification的提示音为系统默认提示声音
notification.setLatestEventInfo(this, "提示消息", note, null);
notificationManager.notify(NOTIFICATION_ID, notification);
} // 取消通知
private void cancelNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
}

添加常驻Notification的更多相关文章

  1. Android 添加常驻图标到状态栏

    / * * 如果没有从状态栏中删除ICON,且继续调用addIconToStatusbar,则不会有任何变化.如果将notification中的resId设置不同的图标,则会显示不同的图标 * / p ...

  2. android Notification介绍

    如果要添加一个Notification,可以按照以下几个步骤 1:获取NotificationManager: NotificationManager m_NotificationManager=(N ...

  3. Android之Notification介绍

    Notification就是在桌面的状态通知栏.这主要涉及三个主要类: Notification:设置通知的各个属性. NotificationManager:负责发送通知和取消通知 Notifica ...

  4. Notification NotificationManager RemoteViews PendingIntent

    Notification和NotificationManager :可以用来实现可视化的消息通知等,比如:下载进度显示,消息显示,广播的内容等 RemoteViews :用于创建自定义的Notific ...

  5. Android中的消息通知(NotificationManager和Notification)

    下面来谈谈notification,这个notification一般用在电话,短 信,邮件,闹钟铃声,在手机的状态栏上就会出现一个小图标,提示用户处理这个通知,这时手从上方滑动状态栏就可以展开并处理这 ...

  6. Android消息通知(notification)和PendingIntent传值

    通知栏的自定义布局:转:http://blog.csdn.net/vipzjyno1/article/details/25248021 拓展 实现自定义的通知栏效果: 这里要用到RemoteViews ...

  7. android学习日记21--消息提示之Toast和Notification

    1.Toast Toast译为土司,类似切片面包,用于弹出比较快速的及时提示信息.当Toast被显示时,虽然它悬浮应用程序最上方,但是并未获得焦点.它的设计就是为了提示有用的信息,而不打扰用户其他操作 ...

  8. Notification使用以及PendingIntent.getActivity() (转)

    public void sendNotification(Context ctx,String message) { //get the notification manager String ns ...

  9. Android Notification通知详细解释

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

随机推荐

  1. oracle参数open_cursors和session_cached_cursor详解!

    SQL> show parameter open_cursors           --每个session(会话)最多能同时打开多少个cursor(游标) NAME               ...

  2. 1307: City Tour

    1307: City Tour Time Limit: 1 Sec  Memory Limit: 128 MB [Submit][Status][Web Board] Description Alic ...

  3. Visual 中控制台程序如何使用MFC类库

    unresolved external symbol __beginthreadex错误的解决Win32 Consle Application使用MFC的一些类如CString时编译时相信会很经常遇到 ...

  4. LeetCode:237

    题目:Delete Node in a Linked List(从列表中删除指定结点) 描述:Write a function to delete a node (except the tail) i ...

  5. 三种硬件平台运行Laxcus大数据系统的表现

    从2.0版本开始,Laxcus大数据管理系统开始支持POWERPC.X86.ARM三种平台.其中X86和ARM又分为32位和64位两种,POWERPC是纯64位,所以实际上共有五种平台,操作系统统一使 ...

  6. Ant 脚本打印系统属性变量、ant内置属性

    Ant 脚本打印系统属性变量.ant内置属性 作用 编写ant脚本的时候,经常会引用到系统属性,本脚本用于打印系统常用属性(System.getProperties)与环境变量(Environment ...

  7. jQuery Mask

    <script type="text/javascript" src="/assets/mask/jquery.mask.min.js"></ ...

  8. 使用Code First 创建数据库

    这是一个控制台程序,作用是通过Code First创建数据库. 1.添加EntityFrameWork的引用. 2.添加类 CodeFirstTest1.cs using System; using ...

  9. IE CSS HACK

    IE 属性值 HACK .test { background:blue; /*所有浏览器*/ background:yellow\9; /*所有IE浏览器*/ background:green\0; ...

  10. Oracle笔记 七、PL/SQL 异常处理

    --异常处理 declare sNum number := 0; begin sNum := 5 / sNum; dbms_output.put_line(sNum); exception when ...