android - 不带抬头视图的通知
问题描述
这可能与这个问题重复, 但仍然无法在没有抬头视图的情况下实施通知。
问题陈述:想在播放歌曲时显示通知。将一个通知与浮动在窗口顶部的音乐服务绑定(显示平视视图),这非常烦人。
有什么方法可以禁用该抬头视图,只想在状态栏中显示一个小图标。
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL)
.setContentTitle("titile")
.setContentText("desc")
.setSmallIcon(R.drawable.logo)
.setColor(getResources().getColor(R.color.colorPrimary))
.setPriority(NotificationCompat.PRIORITY_LOW)
.setAutoCancel(true);
Notification notification = notificationBuilder.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(
CHANNEL, "Halt", NotificationManager.IMPORTANCE_NONE
);
mNotificationManager.createNotificationChannel(notificationChannel);
}
mNotificationManager.notify(NOTIFICATION_ID, notification);
解决方案
花了一些时间后,我只是卸载并重新安装应用程序并开始工作。
越野车岩石
推荐阅读
- windows - 在 Windows 上使用 gcc/g++ 构建 CMake 失败
- c# - DropDownList 的编辑器模板,无法将属性从视图绑定到模板
- python - Python 中的 N 诅咒:如何捕捉和打印非 ascii 字符?
- android - 添加帖子时出现格式错误
- javascript - 我们如何在其中一个成员连接 10 分钟然后断开连接 5 分钟然后再次加入时录制一对一流
- mysql - 临时表更新
- r - 给我一个月的所有日期列表的功能
- java - azure rest api 文件创建。无法对请求进行身份验证。格式正确,包括签名。响应代码:403 这个错误
- php - 插入操作无法通过 Angular JS
- django - 在 Django REST Framework 中使用序列化程序添加相关的 ForeignKey 字段