我剛剛導入了一個android項目,並且在通知部分中,我必須使用setLatestEventInfo。但Android Studio說不能解決方法setLatestEventinfo。這裏是我的代碼片段,請您幫忙修改我的代碼,而回答無法在android通知中解析方法setLatestEventInfo
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,"CEPF Mobile",0);
Intent notify_intent = new Intent(context,SpecialSerivceReportActivity.class);
notify_intent.putExtra("filename", "Special Service Report");
notify_intent.putExtra("URL", urls[0]);
PendingIntent contentIntent = PendingIntent.getActivity(context,(int)System.currentTimeMillis(),notify_intent,PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, "CEPF Mobile", "New post in Special Service Report", contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND ;
nm.notify((int)System.currentTimeMillis(),notification);
}
else if(message.equalsIgnoreCase("Special Columnist Blog"))
{
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,"CEPF Mobile",0);
Intent notify_intent = new Intent(context,SpecialSerivceReportActivity.class);
notify_intent.putExtra("filename", "Special Columnist Blog");
notify_intent.putExtra("URL", urls[1]);
PendingIntent contentIntent = PendingIntent.getActivity(context,(int)System.currentTimeMillis(),notify_intent,PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, "CEPF Mobile", "New post in Special Columnist Blog", contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND ;
nm.notify((int)System.currentTimeMillis(),notification);
}
同樣在這裏,儘管在Eclipse中,在代碼中我還沒有碰過一段時間,從那時起對Eclipse,ADT和Android SDK進行了一些更新。 API文檔沒有提及該方法 - 儘管該代碼用於運行。因此,這不可能是Android Studio的罪魁禍首。 – user149408