系统服务-----NotificationManager
熟悉api事例笔记:
package com.test; import com.example.test.R; 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; public class MainActivity extends Activity {
private static final int NOTIFICATION_FLAG = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
} public void notificationMethod(View view) {
// 在Android进行通知处理,首先须要从系统哪里获得通知管理器NotificationManager,它是一个系统Service。
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
switch (view.getId()) {
case R.id.btn1:
// 创建一个PendingIntent,和Intent相似,不同的是因为不是立即调用,须要在下拉状态条出发的activity,所以採用的是PendingIntent,即点击Notification跳转启动到哪个Activity
PendingIntent pi = PendingIntent.getActivity(this,0,new Intent(this,MainActivity.class),0);
Notification notyfi1 = new Notification();
notyfi1.icon = R.drawable.ic_launcher;
notyfi1.tickerText = "您有一天新消息请注意查收 ";
notyfi1.when = System.currentTimeMillis();
notyfi1.flags |= Notification.FLAG_AUTO_CANCEL;// FLAG_AUTO_CANCEL表明当通知被用户点击时。通知将被清除。
notyfi1.number = 1;
notyfi1.setLatestEventInfo(this, "标题", "内容", pi);
//通过通知管理器来发起通知。假设id不同。则每click,在statu那里添加一个提示
nm.notify(NOTIFICATION_FLAG,notyfi1);
break; default:
break;
}
}
}
系统服务-----NotificationManager的更多相关文章
- AndroidAnnotations简单示例
@EActivity(R.layout.activity_main) public class MainActivity extends Activity { @ViewById(R.id.textV ...
- Android -- 通知栏的使用
1. 效果图
- [Android] Toast问题深度剖析(二)
欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者: QQ音乐技术团队 题记 Toast 作为 Android 系统中最常用的类之一,由于其方便的api设计和简洁的交互体验,被我们所广泛采用 ...
- 依赖注入框架之androidannotations
主页: http://androidannotations.org/ 用途: 1. 使用依赖注入Views,extras,System Service,resources 2. 简化线程模型 3. 事 ...
- Android中的消息通知(NotificationManager和Notification)
下面来谈谈notification,这个notification一般用在电话,短 信,邮件,闹钟铃声,在手机的状态栏上就会出现一个小图标,提示用户处理这个通知,这时手从上方滑动状态栏就可以展开并处理这 ...
- Android系统服务-简介
http://blog.csdn.net/chenyafei617/article/details/6577907 Introduction 我们知道Android系统服务挺多的,做程序时经常会用到, ...
- Android学习(十五) 系统服务
一.常用系统服务 后台Service在系统启动时被SystemService开启 1.MountService:监听是否有SD卡安装和移除. 2.ClipboardService:提供剪切板功能. 3 ...
- iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总
--系统应用与系统服务 iOS开发过程中有时候难免会使用iOS内置的一些应用软件和服务,例如QQ通讯录.微信电话本会使用iOS的通讯录,一些第三方软件会在应用内发送短信等.今天将和大家一起学习如何使用 ...
- 添加自编译的apache为linux系统服务
步骤1添加服务脚本 #cp /app/apache2/bin/apachectl /etc/rc.d/init.d/httpd #ln -s /etc/rc.d/init.d/httpd /etc/r ...
随机推荐
- 洛谷——P1991 无线通讯网
P1991 无线通讯网 题目描述 国防部计划用无线网络连接若干个边防哨所.2 种不同的通讯技术用来搭建无线网络: 每个边防哨所都要配备无线电收发器:有一些哨所还可以增配卫星电话. 任意两个配备了一条卫 ...
- OC语言基础之代码的封装
1.封装的注意点 1: // 成员变量尽量不要用@public 2: // @public 3: int age; 1: //@public 2: // 只读(readonly):只允许外界访问我的n ...
- EF执行存储工程报错 String[4]: Size 属性具有无效大小值 0。
EF中执行存储过程报错 String[4]: Size 属性具有无效大小值 0 排查后是如下问题所致,给定的参数没有设定大小(加入红框内的就可以了) private string GetCode(MC ...
- 【Java】java注解@Transient的作用, 配合JPA中时间段的查询
java注解@Transient的作用 @Transient标注的属性,不会被ORM框架映射到数据库中. 用于数据库表字段和java实体属性不一致的时候,标注在属性上使用. 例如时间段的查询 查询 R ...
- crossapp的屏幕适配
1.分辨率是的某个尺寸大小的屏幕里的像素点数ppi 2.crossapp茶用iphone4为基准比例值为1 3.其它分辨率设备的换算dp = px * 320/ 屏幕PPI 4.crossapp里点. ...
- YAML 在Python中的应用
编程免不了要写配置文件,怎么写配置也是一门学问. YAML 是专门用来写配置文件的语言,非常简洁和强大,远比 JSON 格式方便. YAML在python语言中有PyYAML安装包,下载地址:http ...
- redhat mount iso as one yum repository
prepare redhat DVD iso rhel-server-6.4-x86_64-dvd.iso mount cd / mkdir /mnt/rhel mount -o loop rhel- ...
- node-表单验证
var http = require('http'); var url = require('url'); var fs = require('fs'); var querystring = requ ...
- Angular 学习笔记——$interpolateProvide
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- nginx静态文件缓存
open_file_cache max=65535 inactive=30s; open_file_cache 打开缓存的同时也指定了缓存最大数目,以及缓存的时间 open_file_cache_va ...