如何修复方法setLatestEventInfo(AlarmService_Service,String,CharSequences,PendingIntent)未定义类型通知
请帮助解决此错误
这是剧本:
/**
* Show a notification while this service is running.
*/
private void showNotification() {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = "Doctor Jokes SF";
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.icon, text,System.currentTimeMillis());
Intent notifyIntent = new Intent(this, MainActivity.class);
// Sets the Activity to start in a new, empty task
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// Set the info for the views that show in the notification panel.
notification.setLatestEventInfo(this, quote.getBody(), text, contentIntent);
notification.flags |=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
//Define sound URI
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.sound = soundUri;
// Send the notification.
// We use a layout id because it is a unique number. We use it later to cancel.
mNM.cancelAll();
mNM.notify(0, notification);
}