android 45 通知







package com.sxt.day07_01; import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setListener();
} private void setListener() {
findViewById(R.id.btnSendNotification).setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
//创建启动目标Activity的Intent对象,点击通知后跳到SecondActivity页面
Intent intent=new Intent(MainActivity.this, SecondActivity.class);
//创建PendingIntent对象
PendingIntent pi=PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
//创建Notification对象
Notification notif=new Notification(R.drawable.ic_launcher, "通知来啦!", System.currentTimeMillis());//没有下拉的时候通知图片,通知题目,通知发送时间
//设置点击通知的监听
notif.setLatestEventInfo(MainActivity.this, "您右16款软件可以更新", "点击开始更新", pi);//把下拉栏拉下来以后,通知显示的文本。
//创建通知管理器对象
NotificationManager manager=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);//getSystemService获得系统的服务
//发送通知
manager.notify(99, notif);//99是通知的id值
// manager.cancel(99);
}
});
} }
android 45 通知的更多相关文章
- android: 使用通知
8.1 使用通知 通知(Notification)是 Android 系统中比较有特色的一个功能,当某个应用程序希望向 用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发 ...
- Android消息通知(notification)和PendingIntent传值
通知栏的自定义布局:转:http://blog.csdn.net/vipzjyno1/article/details/25248021 拓展 实现自定义的通知栏效果: 这里要用到RemoteViews ...
- Android Notification通知详细解释
Android Notification通知具体解释 Notification: (一).简单介绍: 显示在手机状态栏的通知. Notification所代表的是一种具有全局效果的通 ...
- Android灯光系统--通知灯深入分析【转】
本文转自:https://www.cnblogs.com/lkq1220/p/6406261.html Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 ...
- 【转】Android中通知的提示音、震动和LED灯效果小例子
通知(Notification)是 Android 系统中比较有特色的一个功能,当某个应用程序希望向用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发出一条通知后,手机最上方 ...
- Android灯光系统--通知灯深入分析
Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 getSystemService(获得通知服务) 构造notification 类别 其他参数(颜色, ...
- Android Service 通知Activity更新界面的方法研究
Android Service 通知Activity更新界面的方法研究 Android的最重要的组件式service和activity,那么在使用的过程中,我们最常遇到的问题是他们之间的通信问题. ...
- Android Notification通知简介
Android Notification通知简介 根据activity的生命周期,在activity不显示时,会执行onStop函数(比如按下home键),所以你在onStop函数(按退出键除外)里面 ...
- Android Notification通知详解
根据activity的生命周期,在activity不显示时,会执行onStop函数(比如按下home键),所以你在onStop函数(按退出键除外)里面把notification放在通知栏里,再此显示时 ...
随机推荐
- JS-运动框架
写这段代码,是因为之前看过某前RD写过,但在测试过程中发现有不完美的地方. 问题在于判断运动停止条件这里,对于之前停止的判断太片面,只能判断一个条件值时的情况,对于多条件时,会发现运动后的各项值并未达 ...
- DAC,MAC和SELinux,SEAndroid
1. 被ROOT了怎么办 2. SELinux 3. SEAndroid 4. JB(4.3) MR2的漏洞弥补 ------------------------------------------- ...
- window scipy install
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy whl包,使用pip install xx.whl 安装 1:先安装 numpy+mkl. whl ...
- ASP.NET MVC轻教程 Step By Step 8——路由
在前面的教程里,细心的你可能会有个疑问,就是地址栏输入/Home/Write就可以进入留言页面.无论是静态HTML还是ASP/ASP.NET.PHP,URL都是和某个页面相关.比如假设有个URL是“w ...
- Nodejs and json
http://cnodejs.org/topic/51bbe16960af11cd33304b75 http://www.cnblogs.com/nano/archive/2012/05/09/249 ...
- Origin null is not allowed by Access-Control-Allow-Origin
http://www.cnblogs.com/accessking/archive/2012/05/12/2497000.html http://bbs.csdn.net/topics/3903099 ...
- OS X Lion版 如果我忘记了我的账户密码 我该怎么办?
来到了 mac os x lion 10.7 上. 忘记密码的朋友不会减少. 除了努力回忆和询问自己的老婆外还有其他办发不? 那是自然有的. 帐户密码很重要虽然有时候我们设置了帐户自动登陆但是如果您需 ...
- c++ 名字粉碎(name mangling)
转自Ibm: Name mangling is the encoding of function and variable names into unique names so that linker ...
- 最好的JAVA IDE IntelliJ IDEA使用简介(一)—之界面元素
打开IDEA,(当第一次打开的时候出现的是一个欢迎页面,随便创建一个project来进入到IDEA的主界面),主界面显示如下: 主界面由6个主要区域组成(图中红色数字标注的) 1.菜单和工具栏 2.导 ...
- 一起啃PRML - Preface 前言
一起啃PRML - 前言 Preface @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ PRML,Pattern Recognition and M ...