android下录音后台将程序图标显示在状态栏上
来源:互联网 发布:visio软件结构图 编辑:程序博客网 时间:2024/05/19 19:44
http://libin52008.blog.163.com/blog/static/105327187201172711438758/
http://hi.baidu.com/eheghfxhsdcdkzr/item/97e304d4acda78d5251f40da
android下后台将程序图标显示在状态栏上
根据activity的生命周期,在activity不显示时,会执行onStop函数,所以你在onStop函数(按退出键除外)里面把notification放在通知栏里,再此显示时,把notification从通知栏里去掉。
或者,只要程序在运行就一直显示通知栏图标,这样简单点。
privatevoid showNotification() {
// 创建一个NotificationManager的引用
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
// 定义Notification的各种属性
Notification notification =new Notification(R.drawable.icon,
"天籁之音播放器", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中
notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在点击了通知栏中的"清除通知"后,此通知不清除,经常与FLAG_ONGOING_EVENT一起使用
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults = Notification.DEFAULT_LIGHTS;
notification.ledARGB = Color.BLUE;
notification.ledOnMS =5000;
// 设置通知的事件消息
CharSequence contentTitle ="天籁之音正在播放……"; // 通知栏标题
CharSequence contentText ="ameyume"; // 通知栏内容
Intent notificationIntent =new Intent(context, MusicDemo.class); // 点击该通知后要跳转的Activity
PendingIntent contentItent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentItent);
// 把Notification传递给NotificationManager
notificationManager.notify(0, notification);
}
去掉通知栏通知的方法
// 启动后删除之前我们定义的通知
NotificationManager notificationManager = (NotificationManager) this
.getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(0);
http://hi.baidu.com/eheghfxhsdcdkzr/item/97e304d4acda78d5251f40da
android下后台将程序图标显示在状态栏上
根据activity的生命周期,在activity不显示时,会执行onStop函数,所以你在onStop函数(按退出键除外)里面把notification放在通知栏里,再此显示时,把notification从通知栏里去掉。
或者,只要程序在运行就一直显示通知栏图标,这样简单点。
privatevoid showNotification() {
// 创建一个NotificationManager的引用
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
// 定义Notification的各种属性
Notification notification =new Notification(R.drawable.icon,
"天籁之音播放器", System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中
notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在点击了通知栏中的"清除通知"后,此通知不清除,经常与FLAG_ONGOING_EVENT一起使用
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults = Notification.DEFAULT_LIGHTS;
notification.ledARGB = Color.BLUE;
notification.ledOnMS =5000;
// 设置通知的事件消息
CharSequence contentTitle ="天籁之音正在播放……"; // 通知栏标题
CharSequence contentText ="ameyume"; // 通知栏内容
Intent notificationIntent =new Intent(context, MusicDemo.class); // 点击该通知后要跳转的Activity
PendingIntent contentItent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentItent);
// 把Notification传递给NotificationManager
notificationManager.notify(0, notification);
}
去掉通知栏通知的方法
// 启动后删除之前我们定义的通知
NotificationManager notificationManager = (NotificationManager) this
.getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(0);
- android下录音后台将程序图标显示在状态栏上
- android怎么判断程序在后台运行,让后台将程序图标显示在状态栏上?
- android让后将程序图标显示在状态栏
- Android应用图标在状态栏上显示实现原理
- android怎么判断程序在后台运行,让后将程序图标显示在状态栏
- android怎么判断程序在后台运行,让后将程序图标显示在状态栏
- android怎么判断程序在后台运行,让后将程序图标显示在状态栏
- 在mac状态栏上显示应用程序图标,代码
- 实现将程序图标显示在系统托盘
- 程序图标不显示在任务栏上
- android 状态栏显示运行图标
- 将版本信息显示在App图标上
- 将版本信息显示在App图标上
- 在状态栏上显示会闪烁的图标(类似qq消息提示)
- 为什么状态栏上的GPS图标在GPS程序退出后不会自动消失
- Android Wi-Fi StatusBar(状态栏)流量上下行图标显示流程
- 网页中多个图标在一张图片上,使用css将各图标显示
- Android下添加状态栏图标的方法
- java语言学习历程小结(四)
- 使用JavaScript中的ActiveXObject填充并设置Excel格式
- 向量概念,零向量,向量取反,计算向量的长度,单位向量
- Ubuntu安装Fcitx(小企鹅五笔输入法)
- 环上的游戏(贪心-博弈)
- android下录音后台将程序图标显示在状态栏上
- Ubuntu切换jdk版本的方法
- Hibernate N+1 问题
- cocos2d类图
- Android 屏幕像素计算方法
- android学习笔记之Intent&Intent filter
- 完数
- Android C++层如何判断ProjectConfig.mk中定义的宏
- 我们拿这10年做什么——有多少人知道你