Notification通知
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this);
builder.setContentTitle("标题");
builder.setContentText("内容");
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setAutoCancel(true);
Intent intent = new Intent();
intent.setClass(MainActivity.this, SecondActivity.class);
PendingIntent pIntent = PendingIntent.getActivity
(MainActivity.this, 1, intent, PendingIntent.FLAG_ONE_SHOT);
builder.setContentIntent(pIntent);
notification = builder.build();
manager.notify(1, notification);
}
});

final NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this);
builder.setContentTitle("标题");
builder.setContentText("内容");
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setDefaults(Notification.DEFAULT_ALL);
progress = 0;
final Timer timer = new Timer();
timer.schedule(new TimerTask() { @Override
public void run() {
progress+=10;
if(progress>100){
progress = 100;
timer.cancel();
}
builder.setProgress(100, progress, false);
notification = builder.build();
manager.notify(2, notification);
}
}, 1000 , 1000);

自定义:
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this);
builder.setContentTitle("标题");
builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.ic_launcher);
// 创建RemoteView并显示在通知中
RemoteViews views = new RemoteViews(getPackageName(), // 当前所在应用的包
R.layout.notification);
views.setTextViewText(R.id.textview, "普通文本");
views.setImageViewResource(R.id.image, R.drawable.ic_launcher);
builder.setContent(views);// 设置自定义的通知
notification = builder.build();
manager.notify(3, notification);
Notification通知的更多相关文章
- iOS - Notification 通知
1.Notification 通知中心实际上是在程序内部提供了消息广播的一种机制,它允许我们在低程度耦合的情况下,满足控制器与一个任意的对象进行通信的目的.每一个 iOS 程序(即每一个进程)都有一个 ...
- [iOS基础控件 - 6.10] Notification 通知机制
A.定义 iOS程序都有一个NSNotificationCenter的单例对象,用来负责发布不同对象之间的通知 任何对象都能够在NSNotificationCenter发布通知,发 ...
- Notification (通知)的 新版和旧版用法
Notification (通知)的 新版和旧版用法 一.先来看旧版,Api 11 之前的用法: NotificationManager manager = (NotificationManage ...
- Android Notification通知详细解释
Android Notification通知具体解释 Notification: (一).简单介绍: 显示在手机状态栏的通知. Notification所代表的是一种具有全局效果的通 ...
- 配置 SQL Server Email 发送以及 Job 的 Notification通知功能
配置 SQL Server Email 发送以及 Job 的 Notification通知功能 在与数据库相关的项目中, 比如像数据库维护, 性能警报, 程序出错警报或通知都会使用到在 SQL Ser ...
- Android开发——Notification通知的各种Style详解
本来是想与之前讲解使用Notification通知使用一起写的,查看了资料,觉得有必要将这Style部分单独拿出来讲解 前篇:Android开发——Notification通知的使用及Notifica ...
- Android开发——Notification通知的使用及NotificationCopat.Builder常用设置API
想要看全部设置的请看这一篇 [转]NotificationCopat.Builder全部设置 常用设置: 设置属性 说明 setAutoCancel(boolean autocancel) 设置点击信 ...
- 配置 SQL Server 2008 Email 发送以及 Job 的 Notification通知功能
SQL Server 2008配置邮件的过程就不写了,网上的案例太多了. http://www.cnblogs.com/woodytu/p/5154526.html 这个案例就不错. 主要写下配置完后 ...
- element ui 的Notification通知如何加 a 标签和按钮,并弹多个
前言:工作中需要在页面右下角弹出很多个提醒框,提醒框上有一个可点击的a标签,并有一个按钮,同时还需要一次性关闭所有的弹出框.转载请注明出处:https://www.cnblogs.com/yuxiao ...
- 适配 通知 Notification 通知渠道 前台服务 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
随机推荐
- Node.js 创建HTTP服务器(经过测试,这篇文章是靠谱的T_T)
Node.js 创建HTTP服务器 如果我们使用PHP来编写后端的代码时,需要Apache 或者 Nginx 的HTTP 服务器,并配上 mod_php5 模块和php-cgi. 从这个角度看,整个& ...
- cocos基础教程(6)坐标与锚点讲解
坐标系详解 Cocos2d-x坐标系和OpenGL坐标系相同,都是起源于笛卡尔坐标系.原点为屏幕左下角,x向右,y向上. 世界坐标系(World Coordinate) VS 本地坐标系(Node L ...
- IIS计数器
Bytes Total/sec 是 Bytes Sent/sec 与 Bytes Received/sec 的总和.这是 Web 服务每秒传输的总字节数. Cache Total Turnover R ...
- 【NGUI】grid下面的item的重复利用
http://blog.csdn.net/u012091672/article/details/21159075解决的问题 使用grid放置item的时候,每次数据可能都不一样,但是每次都删除grid ...
- [POJ1383]Labyrinth
[POJ1383]Labyrinth 试题描述 The northern part of the Pyramid contains a very large and complicated labyr ...
- ORACLE10G工作原理
数据库查询语句内部执行过程 Select * from xxx 步骤 分析阶段(parse) 1. 共享池库高速缓存有没有该语句.如果有直接返回结果. 2. 语法分 ...
- nginx(三)初步搭建nginx虚拟主机
上面就是nginx基于域名.ip访问的配置,掌握住格式,就很好配置了. 一.基于域名的虚拟主机的配置:1.我们在此复习一下DNS的配置:[root@mgmserver /]# hostnamemgms ...
- HDU 3371 kruscal/prim求最小生成树 Connect the Cities 大坑大坑
这个时间短 700多s #include<stdio.h> #include<string.h> #include<iostream> #include<al ...
- PHP快速抓取快递信息
<?php header("Content-type:text/html;charset=utf-8"); /** * Express.class.php 快递查询类 * @ ...
- 进入git diff 界面,无法继续输入命令
在终端,输入 git diff 文件名 命令之后回车,显示如下界面: 在网上查找,说输入q回车即可退出显示,执行,果然有效,输入h可以显示所有命令 命令如下: SUMMARY OF LESS COM ...