简体   繁体   English

我们如何在Android中以编程方式为“锁定屏幕通知和徽章图标”等应用启用通知设置

[英]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_MAXPRIORITY_HIGH的通知显示在一个小的浮动窗口中。

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android设置应用程序图标时的应用程序图标上的徽章编号或在接收Facebook应用程序等通知时被杀死 - On Android setting badge number on app icon when app is in background or killed when receiving notification like facebook app 如何在Android应用程序(如iPhone)上创建通知图标徽章 - How to create notification icon badge on Android apps (like iPhone) 如何以编程方式在主屏幕应用程序图标android中设置徽章编号? - How set badge number in home screen app icon android programatically? 在android中的app图标上添加通知徽章 - adding notification badge on app icon in android Android App Icon中的通知计数徽章 - Notification Count Badge in Android App Icon 如何使用 Ionic 2 在 Android 应用程序图标中增加徽章计数通知? - How to increase badge count notification in the Android app icon using Ionic 2? 如何在后台在Android应用程序图标上计算推送通知消息徽章 - How to count Push notification message badge on android app icon in background 如何以编程方式在Android上的应用程序图标上显示推送通知徽章计数? - How to show push notification badge count on app icon in android programmatically? Android:如何为图标创建通知徽章? - Android: how to create a notification badge for an icon? 我可以在Android和小通知图标上禁用通知徽章吗? - Can I disable notification badge on android and small notification icon?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM