【发布时间】:2021-11-18 05:39:42
【问题描述】:
当服务在后台运行时,我可以隐藏通知“应用程序名称正在运行”吗?
我的通知是:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.SetDefaults((int)NotificationDefaults.All)
.SetSmallIcon(Resource.Drawable.navigation_empty_icon)
.SetVibrate(new long[] { 100, 200, 300, 400, 500, 400, 300, 200, 400 })
.SetSound(null)
.SetChannelId(channelId)
.SetPriority(NotificationCompat.PriorityMin)
.SetAutoCancel(true)
.SetContentTitle("")
.SetContentText("")
.SetNotificationSilent()
.SetOngoing(false);
StartForeground(1, builder.Build());
【问题讨论】:
-
隐藏通知是什么意思?如果您希望不弹出通知,可以在 API 级别 26 以下时更改优先级。从 API 级别 26 或以上开始,您需要设置通道优先级。
-
这意味着如何在没有通知的情况下运行 StartForeground?
标签: c# xamarin xamarin.forms xamarin.android background-service