Android中关于setLatestEventInfo()过时以及构建Notification的解决方法
来源:互联网 发布:shell 不在数组 编辑:程序博客网 时间:2024/06/05 18:32
官方说法:
public Notification getNotification () Added in API level 11
This method was deprecated in API level 16. Use build() instead.
在API 11中,通过builder.getNotification()获取Notification对象已经过时了,替代方法是使用builder.builder();
Creating a Notification //创建一个Notification
You specify the UI information and actions for a notification in a NotificationCompat.Builder object. To create the notification itself, you callNotificationCompat.Builder.build(), which returns a Notification object containing your specifications. To issue the notification, you pass the Notification object to thesystem by calling NotificationManager.notify().
通过NotificationCompat.Builder.build()创建一个notification对象,它返回一个你已经创建的notification对象,通过使用 NotificationManager.notify()来进行系统通知
public Notification build ()
Added in API level 16 Combine all of the options that have been set and return a newNotification object.
Notification build ()是在API 16中才加入的,它包括了Notification所需要的所有选项,并返回一个notification对象
Required notification contents
A Notification object must contain the following:
A small icon, set by setSmallIcon()
A title, set by setContentTitle()
Detail text, set by setContentText()
一个Notification对象需要包括以下内容:
一个小图标:builder.setSmallIcon(R.drawable.ic_launcher);
一个标题:builder.setContentTitle("通知的标题");
public Notification getNotification () Added in API level 11
This method was deprecated in API level 16. Use build() instead.
在API 11中,通过builder.getNotification()获取Notification对象已经过时了,替代方法是使用builder.builder();
Creating a Notification //创建一个Notification
You specify the UI information and actions for a notification in a NotificationCompat.Builder object. To create the notification itself, you callNotificationCompat.Builder.build(), which returns a Notification object containing your specifications. To issue the notification, you pass the Notification object to thesystem by calling NotificationManager.notify().
通过NotificationCompat.Builder.build()创建一个notification对象,它返回一个你已经创建的notification对象,通过使用 NotificationManager.notify()来进行系统通知
public Notification build ()
Added in API level 16 Combine all of the options that have been set and return a newNotification object.
Notification build ()是在API 16中才加入的,它包括了Notification所需要的所有选项,并返回一个notification对象
Required notification contents
A Notification object must contain the following:
A small icon, set by setSmallIcon()
A title, set by setContentTitle()
Detail text, set by setContentText()
一个Notification对象需要包括以下内容:
一个小图标:builder.setSmallIcon(R.drawable.ic_launcher);
一个标题:builder.setContentTitle("通知的标题");
一个内容:builder.setContentText("这是通知的内容");
具体如何创建:
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(
MainActivity.this);
builder.setContentTitle("通知的标题");
builder.setContentText("这是通知的内容");
builder.setSmallIcon(R.drawable.ic_launcher);
Notification notification = builder.build();
manager.notify(1, notification);
0 0
- Android中关于setLatestEventInfo()过时以及构建Notification的解决方法
- Android中关于setLatestEventInfo()过时以及构建Notification的解决方法
- Android中关于setLatestEventInfo()过时以及构建Notification的解决方法
- Notification中setLatestEventInfo(),Builder.getNotification()过时
- notification.setLatestEventInfo过时
- Android Notification的setLatestEventInfo()@deprecate
- 关于Notification中setLatestEventInfo方法已弃用
- 关于notification.setLatestEventInfo()的替代方法
- 关于notification.setLatestEventInfo()的替代方法
- 关于notification的使用,setLatestEventInfo方法在新SDK不能使用的解决方法
- 关于notification的使用,setLatestEventInfo方法在新SDK不能使用的解决方法
- 关于notification的使用,setLatestEventInfo方法在新SDK不能使用的解决方法
- 关于setLatestEventInfo(),Builder.getNotification()过时
- Android Notification.setLatestEventInfo(...)
- Android Notification.setLatestEventInfo()警告
- setLatestEventInfo(),Builder.getNotification()过时,Android提供的解决方案
- setLatestEventInfo(),Builder.getNotification()过时,Android提供的解决方案
- setLatestEventInfo(),Builder.getNotification()过时,Android提供的解决方案
- git提交人切换
- input checkbox 复选框大小修改
- UIWebView带Post请求地址
- 深入理解分布式事务
- C# 正则表达式 判断string 是否是数字
- Android中关于setLatestEventInfo()过时以及构建Notification的解决方法
- 内存和硬盘的区别
- ios 解决bug(3)---iOS内存错误EXC_BAD_ACCESS的解决方法
- maven项目打包部署到tomcat+建立个人网站
- 在ubuntu里面安装hadoop操作记录(1)
- 三维散点图:R语言篇
- Android实现定点提醒
- 使用Redis实现抢购的一种思路
- mysql sql 防止重复插入相同的记录实例