gpt4 book ai didi

android - MIUI 抬头通知不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 09:28:36 26 4
gpt4 key购买 nike

我正在努力让我的通知显示抬头或偷看,因为它也被称为。

它在 stock 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());
}

最佳答案

您可以通过两种方式做到这一点。

前往:

  1. 设置

  2. 已安装的应用(迁移到您的应用)

  3. 选择您的应用并转到通知(打开优先级并打开 float 通知)

或者,创建一个远程 View (在 res/layout 中您自己的布局)并设置 customHeadsUpNotification

 RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.notif_custom_view);

notification_builder.createHeadsUpContentView(remoteViews);

不要忘记在进行这些更改后更改 notification_id。

关于android - MIUI 抬头通知不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49097520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com