android - 通知重要性对于前台服务始终为中
问题描述
我已经读过前台服务的通知重要性至少应该是 LOW,但是当我尝试将重要性更改为 LOW 或 HIGH 时,它会被忽略并且通知仍然处于中等重要性。为什么以及如何解决这个问题?
代码片段:
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String id = SYNC_CHANNEL;
String name = getApplicationContext().getResources().getString(R.string.sync_data);
String description = getApplicationContext().getResources().getString(R.string.sync_progress);
int importance = NotificationManager.IMPORTANCE_LOW; // Setting importance
NotificationChannel channel = new NotificationChannel(id, name, importance);
channel.setDescription(description);
channel.enableLights(false);
channel.enableVibration(false);
if (notificationManager == null) {
return;
}
notificationManager.createNotificationChannel(channel);
NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext(), id);
b.setSmallIcon(R.drawable.ic_refresh)
.setContentTitle(getApplicationContext().getResources().getString(R.string.app_name))
.setContentText(getApplicationContext().getResources().getString(R.string.sync_data))
.setOngoing(true);
startForeground(1547, b.build());
解决方案
推荐阅读
- sql - 在单行中选择多个值 - SQL Server
- android - Robo 脚本不适用于不同的语言环境和对话框
- microsoft-graph-api - 按 lastModifiedDateTime 对文件列表进行排序
- java - 根据枚举列表验证字符串列表
- java - 点击 Listeners 到 RecyclerView
- javascript - 使用属性解析 JSON 结果
- python - Python:将标签分配给数组中的值
- node.js - 用户下线/上线时socket断开确认时间延迟
- c# - 使用类中的方法请求查询字符串
- split - 如何从 SnapLogic 中的数组创建多条记录?