我在我的应用程序中使用状态栏通知并在点击按钮时发送它。但是当通知到达时,打开它显示错误的日期(在我的情况下它显示的是1970年1月1日)。
我使用以下代码显示状态栏通知。
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, "Notify", 1000);
Context context = getApplicationContext();
Intent intent = new Intent(this, NotificationActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(context, "TITLE", "MESSAGE", pendingIntent);
notificationManager.notify(R.id.button1, notification);
}
答案 0 :(得分:3)
取自我的博客文章:
http://blog.blundellapps.com/notification-for-a-user-chosen-time/
您应该像这样创建通知:
// This is the icon to use on the notification
int icon = R.drawable.ic_dialog_alert;
// This is the scrolling text of the notification
CharSequence text = "Your notification time is upon us".
// What time to show on the notification
long time = System.currentTimeMillis();
Notification notification = new Notification(icon, text, time);