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放在通知栏里,再此显示时 ...
随机推荐
- Python正则表达式2
- 使用Autofac部署IIS6.0时未能加载文件或程序集“System.Core, Version=2.0.5.0...“
错误信息 .net4.0项目中使用autofac这个IOC容器,在部署在win2003+iis6时出现以下错误. “/”应用程序中的服务器错误. --------------------------- ...
- Prototype:Copy和Clone
原型模式在C#中的实现比较直接,因为只需要继承了IClone的接口,就可以通过重写Clone方法,调用MemberwiseClone()来实现ProtoType的方式. class Test:IClo ...
- SpringSecurity数据库中存储用户、角色、资源
这几天项目中用到了SpringSecurity做登陆安全.所以在这写一下也许可以帮助一下其他人,自己也熟悉一下 SpringSecurity配置文件如下: <beans:beans xmlns= ...
- Objective-C property属性解析
@interface … @property (原子性,可写性,内存管理) id name; @end 原子性: nonatomic, atomic 默认atomic 可写性: rea ...
- Windows常见蓝屏故障分析
转自Windows常见蓝屏故障分析 症状描述: 当您在运行Microsoft Windows 2000/XP/Server 2003.Microsoft Windows Vista/Server 20 ...
- Milk Patterns
poj3261:http://poj.org/problem?id=3261 题意:给定一个字符串,求至少出现k 次的最长重复子串,这k 个子串可以重叠. 题解:还是用后缀数组,求H和后缀数组,然后二 ...
- Java语言基础(一) 标识符
Java标识符的问题: ①不可以以数字开头 int 123number = 0; //错误 ②可以使用任意的货币符号(¥和$等等)中文也可以 int $i = 0; //正确 int ¥i = 1; ...
- 14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率:
14.6.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB 主线程IO 速率: 主线程 在InnoDB 是一个线程 执行各种任务在后台. ...
- ServiceStack.Redis常用操作 - 事务、并发锁
一.事务 使用IRedisClient执行事务示例: using (IRedisClient RClient = prcm.GetClient()) { RClient.Add("key&q ...