我希望我的通知显示在 Android Wear 设备上所有现有通知堆栈的顶部。我读了一份文档,谷歌说我们必须使用方法 setPriority()对于此通知更改通知 statck 中的通知位置。我已经实现了这样的通知:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.extend(wearableExtender)
.setContentTitle(getSpannableTitle(flightDto.getFlightName()))
.setContentText(getSpannableContentText(flightDto, color, status))
.setPriority(NotificationCompat.PRIORITY_MAX);
但这段代码并不需要,如果日历通知最重要,我的通知出现在日历通知下方。 如何在所有通知之上显示此通知?
最佳答案
要在除 setPriotity
之外的所有通知之上显示您的通知,您必须添加 setVibrate
方法。这里的工作代码示例:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.extend(wearableExtender)
.setContentTitle(getSpannableTitle(flightDto.getFlightName()))
.setContentText(getSpannableContentText(flightDto, color, status))
.setPriority(priority)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
关于安卓磨损通知在上面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26740377/