我不知道爲什麼當我顯示通知時,在右上角顯示一些1/4/70日期?那是什麼?我如何擺脫它?Android通知在角落顯示一些奇怪的日期
代碼:
public static void showNotification(int id, String message, String title, String body)
{
int drawable = 0;
switch (id)
{
case NOTIFICATION_NEW_MAIL:
drawable = R.drawable.ic_notify_mail;
break;
case NOTIFICATION_AVAILABLE_TRIPS:
drawable = R.drawable.ic_notify_trip;
break;
}
NotificationManager notifyManager = (NotificationManager)MyApplication.Me.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(drawable, message, SystemClock.elapsedRealtime() + 1000);
notification.defaults |= Notification.DEFAULT_SOUND;
Intent notificationIntent= new Intent(MyApplication.Me, MailListActivity.class);
switch (id)
{
case NOTIFICATION_NEW_MAIL:
notificationIntent = new Intent(MyApplication.Me, MailListActivity.class);
break;
case NOTIFICATION_AVAILABLE_TRIPS:
notificationIntent = new Intent(MyApplication.Me, TripListActivity.class);
break;
}
PendingIntent contentIntent = PendingIntent.getActivity(MyApplication.Me, 0, notificationIntent, 0);
notification.setLatestEventInfo(MyApplication.Me, title, body, contentIntent);
notifyManager.notify(id, notification);
}
截圖:
構造函數已棄用,但我正在開發API7,因此它只是我擁有的東西 – katit 2012-07-29 16:24:46
儘管如此,仍然使用System.getCurrentTimeMillis() - 它可以爲您提供正確的時間。正如我寫的,SystemClock.getEllapsedTime返回自系統啓動以來的時間量。 getCurrentTimeMillis()從1970年1月1日起返回ms,並將正確的時間放在通知框中。另外,如果這項工作可以接受這個答案? – aamit915 2012-07-29 19:35:21
答案已被接受,但它是'System.currentTimeMillis();',而不是'getCurrentTimeMillis()' – katit 2012-07-29 21:14:34