自定义Notification
private static void updateProgressNotification(Context cxt, int appsCount,
int percent, String appName, boolean showTicker) {
NotificationManager nm = (NotificationManager) cxt.getSystemService(
Context.NOTIFICATION_SERVICE);
if (DEBUG) LogHelper.d(TAG, "update notification: " + appsCount + ", appName: " + appName);
if (appsCount == 0) {
nm.cancel(Constants.STATUSBAR_APK_DOWNLOADER_PROGRESS_ID);
return;
} String status = null;
if (appsCount == 1) {
status = cxt.getString(Res.string.download_notification_downloading_one, appName);
} else {
status = cxt.getString(Res.string.download_notification_downloading_more, appsCount);
} RemoteViews downloadView = new RemoteViews(Constants.REAL_PACKAGE_NAME,
Res.layout.notification_apkdownloader_downloading);
downloadView.setTextViewText(Res.id.title, status);
downloadView.setProgressBar(Res.id.progress_bar, 100, percent, false); Intent intent = new Intent(cxt, DownloadMgrActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pi = PendingIntent.getActivity(cxt, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT); Notification notification = new Notification();
notification.icon = NotificationUtils.getGroupIconIdByGroupId(Constants.NOTIFICATION_APPGROUP, Constants.STATE_GREEN);
notification.when = 0;
notification.flags = Notification.FLAG_ONGOING_EVENT;
notification.defaults = 0;
notification.sound = null;
notification.vibrate = null;
notification.contentView = downloadView;
notification.contentIntent = pi;
if (showTicker) {
String ticker = cxt.getString(Res.string.download_notification_downloading_one, appName);
notification.tickerText = ticker;
} nm.notify(Constants.STATUSBAR_APK_DOWNLOADER_PROGRESS_ID, notification);
}
自定义Notification的更多相关文章
- Android自定义Notification并没有那么简单
背景 最近需要实现一个自定义Notification的功能.网上找了找代码,解决方案就是通过RemoteViews来实现.但是在实现过程中遇到不少问题,网上也没有很好的文章描述这些问题,所以在这里做个 ...
- Android -- 系统和自定义Notification
Notification是一种让你的应用程序在不使用Activity的情况下警示用户,Notification是看不见的程序组件警示用户有需要注意的事件发生的最好途径. 作为UI部分,Notifica ...
- android:使用RemoteView自定义Notification
//网上相关内容较少,遂记录下来,备忘. //依然以音乐播放器demo为例. 效果截图 //锤子手机上的效果 step1 准备自定义layout 常规的实现方式,并不会因为是用于notificatio ...
- android自定义Notification通知栏实例
项目有个需求,需要在发送Notification的时候动态给定url的图片.大概思路如下:自己定义一个Notification的布局文件,这样能够很方便设置View的属性. 首先加载网络图片,使用Bi ...
- android显示通知栏Notification以及自定义Notification的View
遇到的最大的问题是监听不到用户清除通知栏的广播.所以是不能监听到的. 自定义通知栏的View,然后service运行时更改notification的信息. /** * Show a notificat ...
- 自定义Notification实现例子
1.自定义view: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a ...
- Android 主页面顶部栏的通知Notification ,可以自定义通知消息栏的风格,并且点击通知栏进人本程序。
常用的程序通知,显示到主页面的顶部栏. package com.lixu.tongzhi; import android.app.Activity; import android.app.Notifi ...
- Notification的基本用法以及使用RemoteView实现自定义布局
Notification的作用 Notification是一种全局效果的通知,在系统的通知栏中显示.既然作为通知,其基本作用有: 显示接收到短消息.即时信息等 显示客户端的推送(广告.优惠.新闻等) ...
- Android notification的使用
notification出现在通知栏中的提示,特别是在4.0以后改进了不少,这里讲得都是基于4.0及4.1以后的. 分类: 1.普通Notification 2.大布局Notification 图1 ...
随机推荐
- HDU2222 Keywords Search [AC自动机模板]
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- Ubuntu添加开机自动启动程序的方法
文章出处:http://hi.baidu.com/gcc_gun/blog/item/fe9bbc4b84e911fa83025cb8.html 1. 开机启动时自动运行程序 Linux加载后, 它将 ...
- 【干货】Laravel --Validate (表单验证) 使用实例
前言 : Laravel 提供了多种方法来验证应用输入数据.默认情况下,Laravel 的控制器基类使用ValidatesRequests trait,该trait提供了便利的方法通过各种功能强大的验 ...
- Entity Framework 学习总结之一:ADO.NET 实体框架概述
http://www.cnblogs.com/xlovey/archive/2011/01/03/1924800.html ADO.NET 实体框架概述 新版本中的 ADO.NET 以新实体框架为特色 ...
- Linux的学习路线图
一.学习Linux的基本要求1. 掌握至少50个以上的常用命令. 2. 熟悉Gnome/KDE等X-windows桌面环境操作 . 3. 掌握.tgz..rpm等软件包的常用安装方法 4. 学习添加外 ...
- jquery------导入jquery.2.2.3.min.js
问题: 导入jquery.2.2.3.min.js后MyEclipse会提示代码有错误 方法: 选中jquery.2.2.3.min.js->右键->选择“MyEclipse”中的“Exc ...
- FileStream文件流的读取和写入(为以后聊天工具的设计基础)
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
- 锋利的jQuery-4--$(document).ready()和window.onload方法的区别
jQuery中的$(document).ready()和JavaScript中的window.onload方法主要有两个方面的不同: 1.执行时机: onload : 网页中所有的元素和元素的关联文件 ...
- SQL防注入程序
1.在Global.asax.cs中写入: protected void Application_BeginRequest(Object sender,EventArgs e){ SqlIn ...
- 取地址符:&
例子: <?php $a=10; $b = &$a; echo $b; $b=15; echo $a; //结果:10和15 //当$b = &$a 时,a,b的地址相同,对a, ...