Android 5.0 Notification的改变
来源:互联网 发布:局域网共享端口开启 编辑:程序博客网 时间:2024/06/05 06:58
到了Android 5.0,发现以前的Notification接口public Notification(int icon, CharSequence tickerText, long when)不再建议使用了,取而代之的是新的方法,如下:
Notification.Builder builder = new Notification.Builder(this);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
builder.setContentIntent(pi);// 设置通知栏点击意图
builder.setLargeIcon(bitmap);// 设置通知大icon(必须采用白色透明图片)
builder.setSmallIcon(int iconId);// 设置通知小icon(必须采用白色透明图片)
builder.setTicker("Ticker...");// 通知首次出现在通知栏时显示的内容,带动画效果
builder.setContentInfo("ContentInfo");// contentinfo显示在小icon的左侧
builder.setContentTitle("ContentTitle");// 设置通知栏标题
builder.setContentText("ContentText");
builder.setPriority(NotificationCompat.PRIORITY_MAX); // 设置该通知优先级
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);//在任何情况下都显示,不受锁屏影响
builder.setAutoCancel(true);// 设置这个标志当用户单击面板就可以让通知将自动取消builder.setDefaults(Notification.DEFAULT_ALL);// 通知的声音,闪光和振动效果为当前用户的默认设置
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, builder.build());
关于Android 5.0通知的图片为白色透明以及Notification的详细参数参考可移步至
http://blog.csdn.net/qq_17766199/article/details/49778339
下面这个博客,还分析了另外2种模式下的Notification(折叠式Notification和悬挂式Notification),可以参考
http://blog.csdn.net/itachi85/article/details/50096609
- Android 5.0 Notification的改变
- Android Notification点击按钮改变内容方案
- Android-Notification的使用
- Android Notification的使用
- android Notification 的使用
- android Notification 的使用
- Android Notification 的使用
- Android-Notification的使用
- android Notification 的使用
- android Notification 的使用
- android Notification 的使用
- android Notification 的使用
- android Notification 的使用
- android Notification的使用
- android notification 的用法
- android notification的用法
- android Notification 的使用
- android Notification 的使用
- json使用总结
- ActiveX(MFC)控件——添加接口及WEB调用
- oracle中实现截取字符串(substr)、查找字符串位置(instr)、替换字符串(replace)
- 细说exports和module.exports
- CentOS 6.5环境下heartbeat高可用集群的实现及工作原理详解
- Android 5.0 Notification的改变
- struts1 action 之间的跳转
- JDK容器与并发—Map—TreeMap
- Python 爬虫学习1
- JAVA集合类图
- 基于稀疏三维变换域协同滤波的图像降噪
- centos下configure zeromq-4.1.2时错误解决方法
- 64位UBUNTU 下安装和配置使用python的spark
- 利用中间件Multer实现上传功能