微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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的升级,而不是您需要避免的特别重要的事情.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐