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的帮助
解决方法:
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的升级,而不是您需要避免的特别重要的事情.