Notifiacation/setLatestEventInfo deprecated
来源:互联网 发布:python 读写文本文件 编辑:程序博客网 时间:2024/06/03 22:40
在使用Notification的时候,发现Notification的方法deprecated,那用什么方法代替呢?
Notification notification = new Notification(iconId, title, System.currentTimeMillis());
notification.setLatestEventInfo(context, ", title, contentItent);
高于API Level 11,低于API Level 16 (Android 4.1.2)版本的系统中,可使用Notification.Builder来构造函数。但要使用getNotification()来使notification实现。此时,前面版本在notification中设置的Flags,icon等属性都已经无效,要在builder里面设置。
Notification.Builder builder = new Notification.Builder(context) .setAutoCancel(true) .setContentTitle("title") .setContentText("describe") .setContentIntent(pendingIntent) .setSmallIcon(R.drawable.ic_launcher) .setWhen(System.currentTimeMillis()) .setOngoing(true); notification=builder.getNotification();
高于API Level 16的版本,就可以用Builder和build()函数来配套的方便使用notification了。
Notification notification = new Notification.Builder(context) .setAutoCancel(true) .setContentTitle("title") .setContentText("describe") .setContentIntent(pendingIntent) .setSmallIcon(R.drawable.ic_launcher) .setWhen(System.currentTimeMillis()) .build();
参考链接:http://www.piaoyi.org/mobile-app/Android-setLatestEventInfo-Handler-SimpleDateFormat.html
0 0
- Notifiacation/setLatestEventInfo deprecated
- setLatestEventInfo
- setLatestEventInfo
- setLatestEventInfo
- setLatestEventInfo
- setLatestEventInfo
- Android关于Notifiacation的封装
- @Deprecated
- Deprecated
- @Deprecated
- Deprecated
- Android Notification.setLatestEventInfo(...)
- Android:setLatestEventInfo问题
- Android Notification.setLatestEventInfo()警告
- 替代setLatestEventInfo()的方法
- notification.setLatestEventInfo过时
- setLatestEventInfo 高版本替换
- Cannot Resolve Method setLatestEventInfo
- spring配置json
- 收藏网站26
- Android layer type与WebView白屏以及WebView不随动画而动的问题
- 解决ScrollView嵌套ListView显示不全问题
- 收藏网站27
- Notifiacation/setLatestEventInfo deprecated
- web2.0之ajax
- 编译原理系列之一
- Django数据API
- android开发资源网站,下载各版本SDK源码、Android Studio、NDK等
- 漏洞修复
- SpringMVC整合JPA小结
- Hadoop—Hadoop1.X和2.X安装练习
- jQuery中的.bind()、.live()和.delegate()之间区别分析