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 通知的更多相关文章

  1. android: 使用通知

    8.1   使用通知 通知(Notification)是 Android 系统中比较有特色的一个功能,当某个应用程序希望向 用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发 ...

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

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

  3. Android Notification通知详细解释

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

  4. Android灯光系统--通知灯深入分析【转】

    本文转自:https://www.cnblogs.com/lkq1220/p/6406261.html Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 ...

  5. 【转】Android中通知的提示音、震动和LED灯效果小例子

    通知(Notification)是 Android 系统中比较有特色的一个功能,当某个应用程序希望向用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发出一条通知后,手机最上方 ...

  6. Android灯光系统--通知灯深入分析

    Android灯光系统--通知灯深入分析 通知的类别 声音 振动 闪灯 APP如何发出通知灯请求 getSystemService(获得通知服务) 构造notification 类别 其他参数(颜色, ...

  7. Android Service 通知Activity更新界面的方法研究

    Android Service 通知Activity更新界面的方法研究   Android的最重要的组件式service和activity,那么在使用的过程中,我们最常遇到的问题是他们之间的通信问题. ...

  8. Android Notification通知简介

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

  9. Android Notification通知详解

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

随机推荐

  1. 【python】只执行普通除法:添加 from __future__ import division

    from __future__ import division 注意future前后是两个下划线

  2. JS面向对象思想(OOP)

    直接看js好了,模拟创建一个奥运会 function 奥运会Class(主题) { // 删除主题 // delete this.主题; this.主题 = 主题; this.开幕时间; this.闭 ...

  3. KVC 与 KVO 理解-b

    KVC 与 KVO 是 Objective C 的关键概念,个人认为必须理解的东西,下面是实例讲解. Key-Value Coding (KVC) KVC,即是指 NSKeyValueCoding,一 ...

  4. 手写js面向对象选项卡插件

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  5. 随着visual studio 2013 发布.带来的一些变化

    1.asp.net a.在2013中, asp.net走向了统一.使用不同的asp.net 框架搭(web forms ,api, mvc )建混合应用 b.身份验证 无身份验证 个人用户账户 (窗体 ...

  6. noip2014 考试总结

    noip:最初估分580,明间数据:570,初测估分:510-570,最终得分:570 这次noip怎么说呢,发挥的还是比较理想吧,不过还是犯了一些“低级错误”,虽然没有造成十分严重的后果,但是还是不 ...

  7. Prefixes and Suffixes

    Codeforces Round #246 (Div. 2) D:http://codeforces.com/contest/432/problem/D 题意:给你一个长度不超过10^5的字符串.要你 ...

  8. MTD应用学习:mtd和mtdblock的区别

    http://my.oschina.net/shelllife/blog/123482 http://www.cnblogs.com/hnrainll/archive/2011/06/09/20760 ...

  9. Linux学习笔记13——使用curses函数库

    一 安装curses库 如果你的Linux系统中curses库,直接敲入命令sudo apt-get install libncurses5-dev,然后就会自动安装curses库,安装好之后敲入命令 ...

  10. JavaScript高级程序设计11.pdf

    与操作字符串有关的最后一个方法是localeCompare(),这个方法比较两个字符串,按照字符串的字母表中的位置分别返回-1,0,1 var stringValue="yellow&quo ...