通知未在ICS 4.0中显示时间(API 14)

时间:2013-08-14 07:01:39

标签: android android-notifications

我使用以下代码来显示通知

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_stat_name)
                .setContentTitle("My notification")
                .setContentText("Hello World!");
Intent resultIntent = new Intent(this, MainActivity.class);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());

根据docs / tutorial

You can set an explicit value with setWhen();
if you don't it defaults to the time that the system received the notification.

问题是我没有收到通知中的defalut time

enter image description here

-------------------- WORK AROUND --------------------- < /强>

使用System.currentTimeMillis()获取当前时间,然后将其传递给when()

long curr_time = System.currentTimeMillis();

mBuilder.setWhen(curr_time);

如果没有解决方法可以解决这个问题,请告诉我。 :)

1 个答案:

答案 0 :(得分:2)

这是早期版本的ICS中的一个错误;从版本4.0.3(fixed here)开始,时间戳应该再次出现。