setLatestEventInfo(),Builder.getNotification()过时,Android提供的解决方案

来源:互联网 发布:安装淘宝的npm镜像 编辑:程序博客网 时间:2024/06/05 03:16
关于setLatestEventInfo(),Builder.getNotification()过时,Android developer提供的原文解决方案:
Notification(int icon, CharSequence tickerText, long when)
This constructor was deprecated in API level 11. Use Notification.Builder instead.
意思是该构造方法在API 11就开始不赞成使用,用Notification.Builder进行替代。
getNotification()
This method was deprecated in API level 16. Use build() instead.
意思是该构造方法在API 16就开始不赞成使用,用
build()
进行替代。
至此,我们得到了处理方案,下面是Android developer给出的一段demo:

Example:

 Notification noti = new Notification.Builder(mContext)         .setContentTitle("New mail from " + sender.toString())         .setContentText(subject)         .setSmallIcon(R.drawable.new_mail)         .setLargeIcon(aBitmap)         .build();
希望对大家有所帮助,转载请注明出处:http://onedaysfriend.blog.163.com/blog/static/1026418122014330101814643/
0 0
原创粉丝点击