Intent resultIntent  = null;
if (!TextUtils.isEmpty(tid)){
resultIntent = new Intent("com.shijiebang.notify");
resultIntent.putExtra("_notify_url", tid);
}else{
resultIntent = new Intent("com.shijiebang.notify2");
} NotificationManager manager = (NotificationManager) context.getSystemService("notification");
// 1.创建一个NotificationCompat.Builder预对象
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
// 2.设置主要信息
// builder.setContentTitle(title_); // 设置内容题目
builder.setContentText(content); // 设置内容文本信息
builder.setSmallIcon(context.getApplicationInfo().icon); // 设置小图标
builder.setContentInfo("contentinfo"); // 设置内容info
builder.setTicker("ticker"); // 对应的Notification对象create时,以消息在标题栏提示
builder.setWhen(System.currentTimeMillis()); // 设置时间
builder.setAutoCancel(true); // 默认点击对应的notification对象后,该对象消失
// 3.设置意图对象
PendingIntent pendingIntent = PendingIntent.getActivity(context, // The 0, // request code
resultIntent, // Intent of the activity to be launched.
PendingIntent.FLAG_UPDATE_CURRENT); // 待补充...
/*
* 隐含执行 MainActivity.this.startActivityForResult(intent, requestCode);
*/
builder.setContentIntent(pendingIntent);
// 4.得到一个notification对象(根据builder预设置信息)
Notification notification = builder.build(); // 5.唤醒notification对象
/*
* 将该notification发送到状态条上,如果id相同且没有消失,则直接更新该notification对象信息
* 否则创建一个Notification实例对象
*/
manager.notify(0, // int id 应用唯一值
notification); // Notification notification 不得设置为null

  

[备忘]Notification的实用的更多相关文章

  1. 实用Shell命令备忘

    开场白:这里简单记录一些常用的bash命令,一则备忘,二来希望可以帮助别人解决一些问题. 1.检测文件是否存在 if [ -f ./foo.txt ] then echo the file exist ...

  2. UITextView -- 基础备忘

    UITextView 这篇文章只涉及到基本的使用,日后会写一些关于结合TextKit的备忘 基本属性 let screenSize = UIScreen.mainScreen().bounds.siz ...

  3. Objective-C教程备忘单

    终极版本的Objective-C教程备忘单帮助你进行iOS开发. 想开始创建你的第一个iOS应用程序么?那么看一下这篇很棒的教程吧:Create your first iOS 7 Hello Worl ...

  4. Mysql又一次整理笔记--woods备忘

    ==============================SQL备忘 CRUD 查询 多表 事件等=============================== ------------------ ...

  5. GIS部分理论知识备忘随笔

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.高斯克吕格投影带换算 某坐标的经度为112度,其投影的6度带和3度带 ...

  6. python序列,字典备忘

    初识python备忘: 序列:列表,字符串,元组len(d),d[id],del d[id],data in d函数:cmp(x,y),len(seq),list(seq)根据字符串创建列表,max( ...

  7. Vi命令备忘

    备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...

  8. ExtJs4常用配置方法备忘

    viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...

  9. [备忘] Automatically reset Windows Update components

    这两天遇到Windows 10的更新问题,官方有一个小工具,可以用来修复Windows Update的问题,备忘如下 https://support.microsoft.com/en-us/kb/97 ...

随机推荐

  1. Android-shareSDK

    1.当数据: 地址:http://sharesdk.mob.com/Download 2.集成数据: DOS命令: java -jar QuickIntegrater.jar    (输入自己的项目名 ...

  2. WinPE:创建 USB 可引导驱动器

    https://msdn.microsoft.com/zh-cn/library/windows/hardware/dn938386(v=vs.85).aspx

  3. spring boot redis缓存入门

    摘要: 原创出处 泥瓦匠BYSocket 下载工程 springboot-learning-example ,工程代码注解很详细.JeffLi1993/springboot-learning-exam ...

  4. +Java中的native关键字浅析(Java+Native+Interface)++

    JNI是Java Native Interface的 缩写.从Java 1.1开始,Java Native Interface (JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的 ...

  5. AngularJS 指令(Directives)实践指南

    指令(Directives)是所有AngularJS应用最重要的部分.尽管AngularJS已经提供了非常丰富的指令,但还是经常需要创建应用特定的指令.这篇教程会为你讲述如何自定义指令,以及介绍如何在 ...

  6. 【转】Java并发编程:Synchronized及其实现原理

    一.Synchronized的基本使用 Synchronized是Java中解决并发问题的一种最常用的方法,也是最简单的一种方法.Synchronized的作用主要有三个:(1)确保线程互斥的访问同步 ...

  7. 【JSOI 2008】 最大数

    [题目链接] 点击打开链接 [算法] 很明显,我们可以用线段树解决此题 只需维护区间最值就可以了 [代码] #include<bits/stdc++.h> using namespace ...

  8. sqlserver2008Mail

    use msdb  GO    DROP PROC MailTim  GO    CREATE PROC MailTim  @Subject NVARCHAR(100),@Body NVARCHAR( ...

  9. 使用cgroups限制MongoDB的内存使用

    cgroups,其名称源自控制组群(control groups)的简写,是Linux内核的一个功能,用来限制,控制与分离一个进程组群的资源(如CPU.内存.磁盘输入输出等). 这个项目最早是由Goo ...

  10. 《MIDINET: A CONVOLUTIONAL GENERATIVE ADVERSARIAL NETWORK FOR SYMBOLIC-DOMAIN MUSIC GENERATION》论文阅读笔记

    出处 arXiv.org (引用量暂时只有3,too new)2017.7 SourceCode:https://github.com/RichardYang40148/MidiNet Abstrac ...