[英]How can we enable notification setting in android for app like “lock screen notification and badge icon” programatically
需要从代码中修改android应用的通知设置,例如启用锁屏通知,徽章图标并实用地启用浮动通知。
You may want to check new features of Android 5.0 APIs for possible options that you can do. 您可能需要检查Android 5.0 API的新功能,以获取可能的选项。
As discussed in Notifications , you can control the visibility level of notifications by calling setVisibility()
and specify one of these values: 如Notifications中所述 ,您可以通过调用setVisibility()
并指定以下值之一来控制通知的可见性级别:
VISIBILITY_PRIVATE
: Shows basic information, such as the notification's icon, but hides the notification's full content.VISIBILITY_PRIVATE
:显示基本信息,例如通知的图标,但隐藏通知的全部内容。VISIBILITY_PUBLIC
: Shows the notification's full content.VISIBILITY_PUBLIC
:显示通知的全部内容。VISIBILITY_SECRET
: Shows nothing, excluding even the notification's icon.VISIBILITY_SECRET
:不显示任何内容,甚至不包括通知的图标。
As for badge icons, you can use the new LauncherApps class to get a list of launchable activities for the current user and any associated managed profiles. 至于徽章图标,您可以使用新的LauncherApps类来获取当前用户和任何关联的托管配置文件的可启动活动的列表。 Your Launcher can make the managed apps visually prominent by appending a work badge to the icon drawable. 通过将工作徽章附加到可绘制图标上,启动器可以使托管应用在视觉上突出。 To retrieve the badged icon, call getUserBadgedIcon()
. 要检索标记的图标,请调用getUserBadgedIcon()
。
Lastly, for floating notifications, you may call Notification.Builder
method when you construct the notification and setPriority()
. 最后,对于浮动通知,可以在构造通知和setPriority()
时调用Notification.Builder
方法。 Notifications with the priority field set to PRIORITY_MAX
or PRIORITY_HIGH
appear in a small floating window if the notification also has sound or vibration. 如果通知中也有声音或振动,则将优先级字段设置为PRIORITY_MAX
或PRIORITY_HIGH
的通知显示在一个小的浮动窗口中。
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.