Android 当前时间之间存在差异的自定义通知
我有文本视图的自定义通知 此通知具有自定义内容:Android 当前时间之间存在差异的自定义通知,android,Android,我有文本视图的自定义通知 此通知具有自定义内容: NotificationCompat.Builder builder = new NotificationCompat.Builder(_context, "id") .setSmallIcon(R.drawable.smoke_icon) .setContent(contentView) .setOnlyAlertOnce(true)
NotificationCompat.Builder builder = new NotificationCompat.Builder(_context, "id")
.setSmallIcon(R.drawable.smoke_icon)
.setContent(contentView)
.setOnlyAlertOnce(true)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setOngoing(prefManager.getPrefNotify());
在这个自定义内容中,我有textview。
在此文本视图中,我可以放置文本:
String currentHour = new SimpleDateFormat("HH:mm", Locale.getDefault()).format(hour);
contentView.setTextViewText(R.id.id_hours, currentHour);
在这个文本视图中,我想输入与当前时间和通知到达时间的差异,如whatsapp或facebook通知“2分钟、10分钟、1天”等
例如,如果我10分钟前收到通知,我可以看到10分钟
我如何创建此项?您所说的
当前时间
和通知到达
是什么意思?请详细说明您需要的具体时间窗口我编辑我的问题您描述的行为(如whatsapp或facebook)在Android上默认处理。收到的任何通知都将在收到时标记时间戳。例如,尝试发送通知,并检查它到达时的外观。您将看到它右侧的时间戳,指示您收到它的时间。是的,我知道使用.setWhen,默认情况下可以看到差异。但是我有自定义容器的自定义通知,我不能使用setWhen