gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:10:03 25 4
gpt4 key购买 nike

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);

在 eclipse 中,我在第二行收到通知,最后第二行的 setLatestEventInfo 被删除。为什么会这样..?任何人都可以澄清错误是什么..?感谢您的帮助

最佳答案

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 - 为什么我在通知中收到弃用警告..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14331753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com