作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在努力让我的通知显示抬头或偷看,因为它也被称为。
它在 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());
}
最佳答案
您可以通过两种方式做到这一点。
前往:
设置
已安装的应用(迁移到您的应用)
选择您的应用并转到通知(打开优先级并打开 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/
所以我有这个界面 public interface EventHandler { public void handleEvent(E event); } 我想为它派生处理事件的类,如下所示
我是一名优秀的程序员,十分优秀!