【发布时间】:2018-08-12 08:16:00
【问题描述】:
我正在努力让我的通知显示抬头或窥视,因为它也被称为。
它适用于现有的 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());
}
【问题讨论】:
-
您是否尝试添加振动模式?
-
嗨,是的,我有。我添加了上面代码的示例。该代码会在 Stock android 和 LineageOS 上生成提示,但不会在 MIUI 上生成...是的,所有通知权限都已授予应用程序。
-
尝试添加 setDefaults(Notification.DEFAULT_ALL)
-
我已经添加了 MIUi 的解决方案,请检查
标签: android notifications android-notifications heads-up-notifications miui