我正在努力让我的通知显示为heads up或者peek,也称为悬浮通知。
在原生Android和Lineage OS API 21-26上工作正常。
如何才能在MIUI 8中使其正常工作?
该应用程序已允许所有通知权限。
这是我的通知代码示例:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, "service_notifications")
.setContentTitle(name)
.setContentText("\uD83D\uDD14" + res.getText(R.string.imminent_arrival_text) + String.valueOf(Long.parseLong(eta) / 60) + res.getText(R.string.minutes_at_text) + simpleETA)
.setSmallIcon(R.drawable.ic_stat_name)
.setContentIntent(null)
.addAction(R.drawable.ic_dialog_close_light, res.getText(R.string.stop_following_label), closePendingIntent)
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.quite_impressed))
.setVibrate(new long[]{1000, 1000})
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_MESSAGE);
notificationManager.notify(
Constants.NOTIFICATION_ID.FOREGROUND_SERVICE,
notification.build());
}