我正在使用以下代码显示通知
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());
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
通知。
-------------------- 解决方法------------
使用获取当前时间System.currentTimeMillis()
,然后将其传递给when()
long curr_time = System.currentTimeMillis();
mBuilder.setWhen(curr_time);
让我知道这是否可以在没有解决的情况下解决。:)