android– 为什么我在通知中收到弃用警告..?

android– 为什么我在通知中收到弃用警告..?,第1张

概述NotificationManagernm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);Notificationn=newNotification(android.R.drawable.stat_notify_more,"MyAlarmRinging",System.currentTimeMillis());Contextcn=MainActivity.this;Cha

notificationmanager nm=(notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE);Notification n=new Notification(androID.R.drawable.stat_notify_more , "My Alarm Ringing", System.currentTimeMillis());Context cn=MainActivity.this;CharSequence title="My Alarm Clock";CharSequence details="Alarm Ringing....!!!";Intent in=new Intent(cn,Alarm.class);PendingIntent p=PendingIntent.getActivity(cn, 0, in, 0);n.setLatestEventInfo(cn,Title,details,p);nm.notify(0,n);

在ecllipse中,我在第二行获得通知,而最后一行中的setLatestEventInfo被删除.为什么会这样..?
任何人都可以澄清什么是错误..?
thanx的帮助

解决方法:

Deprecation是

a status applIEd to features, characteristics, or practices to indicate that they should be avoIDed, typically because they have been superseded.

警告会提醒您目标SDK中已弃用的方法,以便您可以尝试避免使用它.

在此特定上下文中,警告建议您使用Notification.Builder,但是如果您的需要不允许您使用Notification.Builder,由于向后兼容性或其他原因,您可以(很可能)继续使用setLatestEventInfo而不会出现问题.这似乎只是对API的升级,而不是您需要避免的特别重要的事情.

总结

以上是内存溢出为你收集整理的android – 为什么我在通知中收到弃用警告..?全部内容,希望文章能够帮你解决android – 为什么我在通知中收到弃用警告..?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1114505.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存