我创建了自定义通知,我无法在通知栏中显示当前时间..即使我显示System.currentTimeMillis()
,也不会显示。
final Notification notification = new Notification(R.drawable.notificationicon, context.getResources().getString(R.string.notificationheadingtext), System.currentTimeMillis());
notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
notification.when = System.currentTimeMillis();
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion > 20)
{
notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_process);
}
else
{
notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_process_lowerversion);
}
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.sound = alarmSound;
notification.contentIntent = pendingIntent;
notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ic_launcher);
notification.contentView.setTextViewText(R.id.status_text, context.getResources().getString(R.string.notificationheadingtext));
notificationManager.notify(42, notification);