问题:iOS,15,Human,Interface,Guidelines,(4。4),中/英对照翻译版(更新至,2021/12/28)

badge app icon什么意思

iOS 15 Human Interface Guidelines (4.4) 中/英对照翻译版(更新至 2021/12/28)

4. System Capabilities / 系统能力

4.4 Notifications / 通知

Notifications can give people timely and important information, whether the device is locked or in use. For example, notifications can signal when a message arrives, an event is about to occur, new data is available, or there’s a status change.

   通知可给用户提供及时且重要的信息,无论设备是否被锁定或正在使用。例如:通知可在以下情况发出信号:消息到达、事件即将发生、新数据可用、状态发生更改。

4.5.1People appreciate receiving a notification for something they care about, but they don’t always appreciate being interrupted. To help people manage the overall experience, you need to get permission before sending any notifications; the system lets people change this decision — and adjust alert styles, previews, and Siri interactions — in Settings > Notifications. People can also silence all notifications (except for government alerts in some locales) in Settings > Focus.

   用户喜欢收到其关心的事情的通知,但并不始终喜欢被打扰。要帮助用户管理整体体验,则开发者必须在发送任何通知之前获得权限;系统允许用户在设置(Settings) > 通知(Notifications)中更改这个决定(并调整警告样式、预览、Siri 交互)。用户还可在设置(Settings) > 专注模式(Focus)中静音所有通知(某些地区的政府警告除外)。

For developer guidance, see UserNotifications.

Helping People Manage Notifications / 帮助用户管理通知

In iOS 15 and later, people can make fine-grained adjustments to notification behavior by specifying delivery times and setting up a Focus. Delivery scheduling lets people choose whether to receive notification alerts immediately or in a summary that’s delivered at times they choose. A Focus helps people filter notifications during a time period they define for an activity like sleeping, working, reading, or driving.

   在 iOS 15 及更高版本中,用户可通过指定传达时间和设置专注模式来对通知行为进行细粒度调整。传达时间安排允许用户选择是立即接收通知警告,还是在用户选择时间交付的摘要陆中接收通知警告。专注模式会帮助用户在其为睡眠、工作、阅读、驾驶活动定义的时间段内过滤通知。

People identify the contacts and apps that can break through a Focus to deliver notification alerts. In a Work Focus, for example, people might want to receive alerts from work colleagues, family members, and work-related apps as soon as notifications arrive. People might also want to receive all Time Sensitive notification alerts during a Focus. A Time Sensitive notification contains essential information people appreciate getting right away.

   用户可标识出能突破专注模式来交付通知警告的联系人和 app。例如:在工作专注模式(Work Focus)中,用户可能希望在通知到达时立即收到来自同事、家庭成员、工作相关 app 的警告。用户可能还希望在专注模式期间收到所有时间敏感(Time Sensitive)的通知警告。“时间敏感”的通知包含用户喜欢立即收到的关键信息。

   IMPORTANT / 重要

Even though a Focus might delay the delivery of a notification alert, the notification itself is available as soon as it arrives.

   尽管专注模式可能会延迟通知警告的传达,但通知本身是一收到就可用的。

To support these behavior customizations, you first identify the types of notifications your app can send. If your app supports direct communications — like phone calls and messages — you use communication notifications; for all other types of tasks, you use noncommunication notifications. To support communication notifications, you adopt SiriKit intents, which means people can use Siri to customize notification behaviors; for developer guidance, see INSendMessageIntent and UNNotificationContentProviding.

   要支持这些行为定制,则开发者首先要标识 app 可发送的通知类型。如果 app 支持直接通信(例如:电话、信息),则开发者可使用【通信】通知;对于所有其他类型的任务,开发者可使用【非通信】通知。要支持通信通知,则开发者要采用 SiriKit intents,这意味着用户可通过使用 Siri 来定制通知行为。

You specify a system-defined interruption level for each noncommunication notification your app can send. The system uses the interruption level to help determine when to deliver the alert; when a communication notification arrives, the system uses the sender to determine when to deliver the alert.

   开发者为 app 可发送的每个非通信通知指定系统定义的中断等级。系统通过使用中断等级来帮助确定何时发送警告;当通信通知到达时,系统通过使用 sender 来确定何时发送警告。

The system defines four interruption levels for noncommunication notifications:

   系统为非通信通知定义了 4 个中断等级:

· Passive. Information people can view at their leisure, like a restaurant recommendation.“被动”。用户可在其闲暇时查看的信息(例如:餐厅推荐)。· Active (the default). Information people might appreciate knowing about when it arrives, like a score update on their favorite sports team.“主动”(默认)。用户可能喜欢在信息到达时能知道的信息(例如:用户最喜欢的运动队的比分更新)。· Time Sensitive. Information that directly impacts the user and requires their immediate attention, like an account security issue or a package delivery.“时间敏感”。直接影响用户并需要其立即关注的信息(例如:帐户安全问题、包裹递送)。· Critical. Urgent information about personal health and public safety that directly impacts the user and demands their immediate attention. Critical notifications are extremely rare and typically come from governmental and public agencies or healthcare apps. You must get an entitlement to use the Critical interruption level.“严重”。直接影响用户并要求其立即关注的有关个人健康和公共安全的紧急信息。严重通知极为罕见,并通常来自政府、公共机构、医疗保健 app 。开发者必须获得使用严重中断等级的权力。Notification alerts in each system-defined interruption level can behave in the following ways:

   每个系统定义的中断等级中的通知警告可以下列方式运行:

4.5.2

   NOTE / 注意

Because a Critical notification can override the Ring/Silent switch and break through scheduled delivery and Focus, you must get an entitlement to send one.

   因为严重通知可优先于响铃/静音开关并突破预定传达和专注模式,所以开发者必须获得发送严重通知的权利。

Build trust by accurately representing the urgency of each notification. People have several ways to adjust how they receive notifications from your app — including turning off all notifications — so it’s essential to be as realistic as possible when assigning an interruption level. You don’t want people to feel that a notification uses a high level of urgency to interrupt them with low-priority information.

   通过准确表达每个通知的紧迫性来建立信任。用户有多种方法来调整怎样从 app 接收通知(包含:关闭所有通知),所以至关重要的是在分配中断等级时尽可能切合实际。开发者不希望用户觉得通知通过使用高级别紧迫性但低优先级的信息来打断他们。

Use the Time Sensitive interruption level only for notifications that are relevant in the moment. To help people understand the benefits of letting Time Sensitive notifications break through a Focus or scheduled delivery, make sure the notification is about an event that’s happening now or will happen within an hour. The first time a Time Sensitive notification arrives from your app, the system describes how such a notification works and gives people a way to turn it off if they don’t agree that the information requires their immediate attention. Going forward, the system periodically gives people additional opportunities to evaluate how your Time Sensitive notification is working for them. For developer guidance, see UNNotificationInterruptionLevel.

   只为与当前相关的通知使用时间敏感中断等级。要帮助用户理解让时间敏感通知突破专注模式或预定传达的好处,则确保通知是关于正在发生或将在 1 个小时内发生的事件。时间敏感通知第 1 次从 app 处到达时,系统会描述此类通知是怎样工作的,并且如果用户不同意该信息需要其立即关注,则给用户提供关闭时间敏感通知的方法。今后,系统会定期通过为用户提供额外的机会来评估开发者的时间敏感通知对用户的作用。

Never use the Time Sensitive interruption level to send a marketing notification. People may have agreed to receive marketing notifications from your app, but such a notification should never break through a Focus or scheduled delivery setting.

   从不通过使用时间敏感中断等级来发送营销通知。用户可能已经同意从 app 接收营销通知,但此类通知从不应突破专注模式或预定传达的设置。

Designing a Great Notification Experience / 设计出色的通知体验

Aim to provide rich, high-value information that people can understand at a glance.

   旨在提供用户可一目了然的丰富且高价值的信息。

Create a short title if it provides context for the notification content. The system displays your title at the top of a notification where it’s most visible. If you don’t provide a title for a noncommunication notification, the system displays your app name; in a communication notification, the system automatically displays the sender’s name in the title area. The prominence of the notification title area makes it a great place to provide useful information. For example, a noncommunication notification might display a headline, event name, or email subject. If you can only provide a generic title, like New Document, it can be better to let the system display your app name instead.

   如果短标题可为通知内容提供语境,则创建短标题。系统会在通知顶部最显眼的位置显示标题。如果开发者没有为非通信通知提供标题,则系统会显示 app 名称;在通信通知中,系统会在标题区域自动显示发件人姓名。通知标题区域的突出位置是提供有用信息的好地方。例如:非通信通知可能会显示标题、事件名称、电子邮件主题。如果开发者只能提供通用标题(例如:【新文档】),则最好让系统显示 app 名称作为替代。

Write succinct, easy-to-read notification content. Use complete sentences, sentence case, and proper punctuation, and don’t truncate your message — the system does this automatically when necessary. Avoid telling people to open your app, navigate to specific screens, tap specific buttons, or perform other tasks that are hard to remember after the notification disappears.

   编写简洁且易读的通知内容。使用完整句子、句子大小写、正确的标点符号、不要截断消息(必要时,系统会自动这样做)。避免告诉用户打开 app 、导航到特定屏幕、轻按特定按钮、执行在通知消失之后就很难记住的其他任务。

Don’t include sensitive, personal, or confidential information in a notification. You can’t predict what people will be doing when they receive a notification, so it’s essential to avoid including private information that could display on the device screen.

   不要在通知中包含敏感、个人、机密的信息。开发者无法预测用户在收到通知时将会做什么,所以至关重要的是避免包含可能显示在设备屏幕上的私人信息。

Avoid sending multiple notifications for the same thing, even if the user hasn’t responded. People attend to notifications at their convenience. If you send multiple notifications for the same thing, you fill up Notification Center, and people may turn off all notifications from your app.

   避免为同一件事发送多个通知,即使用户没有回复。用户会在方便时处理通知。如果为同一件事发送多个通知,则会填充到通知中心(Notification Center),并且用户可能关闭来自 app 的通知。

Provide generically descriptive text to display when notification previews are hidden. In Settings, people can choose to hide notification previews for all apps. In this situation, the system shows only your app icon and the default title Notification. To give people sufficient context to know whether they want to view the full notification, write body text that succinctly describes the notification content without revealing too many details, like “Friend Request,” “New Comment,” “Reminder,” or “Shipment.” For developer guidance, see hiddenPreviewsBodyPlaceholder.

   通过提供一般描述性文本来在通知预览被隐藏时显示。在设置(Settings)中,用户可选择隐藏所有 app 的通知预览。在这种情况下,系统仅显示 app 图标和默认标题“通知"。要让用户有足够的语境来知道其是否想要查看完整通知,则编写简洁描述通知内容但不透露太多细节的正文(例如:”好友请求“、”新评论“、”提醒“、”发货“)。

Don’t include your app name or icon. The system automatically displays a large version of your app icon at the leading edge of each notification; in a communication notification, the system displays the sender’s contact image — or avatar — badged with a small version of your icon.

   不要包含 app 的名称或图标。系统会在每条通知的前部自动显示大版本的 app 图标;在通信通知中,系统会显示带小版本 app 图标的发件人的联系人图像(或”头像“)。

Consider providing a sound to supplement your notifications. Sound can be a great way to distinguish your app’s notifications and get someone’s attention when they’re not looking at the screen. You can create a custom sound that coordinates with the style of your app or use a system-provided alert sound. If you use a custom sound, make sure it’s short, distinctive, and professionally produced. A notification sound can enhance the user experience, but don’t rely on it to communicate important information, because people may not hear it. Although people can also enable a vibration that accompanies alert sounds, you can’t enable such a vibration programmatically. For developer guidance, see UNNotificationSound.

   考虑通过提供声音来补充通知。声音是区分 app 通知和在用户不看屏幕时引起其注意的好方法。开发者可创建与 app 风格相协调的定制声音或使用系统提供的警告声音。如果使用定制声音,则确保其简短、独特、制作专业。通知声音可增强用户体验,但不要依赖通知声音来传达重要信息,因为用户可能听不到通知声音。尽管用户也可启用伴随警告声音的振动,但开发者无法以编程方式启用此类振动。

Providing Notification Actions / 提供通知行动

A notification can present a customizable detail view that contains up to four buttons people use to perform actions without opening your app. For example, a Calendar event notification provides a Snooze button that postpones the event’s alarm for a few minutes.

   通知可展现可定制的详情视图,其中最多包含 4 个用户无需打开 app 即可执行行为的按钮。例如:日历(Calendar)事件通知会提供将事件闹钟推迟捌几分钟的【小睡(Snooze)】按钮。

People can open a detail view by using the touch and hold gesture to reveal the notification preview or, on an unlocked device, swiping down. For developer guidance, see Handling Notifications and Notification-Related Actions.

   用户可通过使用长按手势或在未锁定的设备上向下滑动来打开详情视图,以此显示通知预览。

Provide beneficial actions that make sense in the context of your notification. Prefer actions that let people perform common, time-saving tasks that eliminate the need to open your app. For each button, use a short, title-case term or phrase that clearly describes the result of the action. Don’t include your app name or any extraneous information in the title, keep the text brief to avoid truncation, and take localization into account as you write the text.

   提供在通知语境中有意义的有益行动。更倾向于让用户执行无需打开 app 、常见、省时的任务的行动。对于每个按钮,使用清楚描述行动结果的简短且标题大写的术语或短语。不要在标题中包含 app 名称或任何无关信息,通过保持文本简短来避免被截断,并在编写文本时考虑本地化。

Don’t provide a notification action that merely opens your app. When people tap a notification or its preview, they expect your app to open the relevant screen, so presenting an action button that does the same thing clutters the detail view and can be confusing.

   不要提供只是打开 app 的通知行动。当用户轻按通知或通知预览时,用户希望 app 打开相关屏幕,所以展现执行相同事情的行动按钮会使详情视图变得混乱且可能令用户困惑。

Avoid providing destructive actions. If you must provide a destructive action, make sure people have enough context to avoid unintended consequences. Actions you identify as destructive appear in red.

   避免提供破坏性的行动。如果开发者必须提供破坏性的行动,则确保用户有足够的语境来避免意外后果。开发者标识的破坏性的行动会显示为红色。

Provide a simple, recognizable glyph for each notification action. A glyph reinforces an action’s meaning, helping people instantly understand what it does. The system displays your glyph on the trailing side of the action title. When you use SF Symbols, you can choose an existing symbol that represents your command or edit a related symbol to create a custom glyph.

   为每个通知行动提供简单且可识别的象形符号。象形符号会强化行动的意义,帮助用户立即理解其作用。系统会在行动标题的尾部显示象形符号。当使用 SF Symbols 时,开发者可通过选择代表开发者命令的现有符号或通过编辑相关符号来创建定制的象形符号。

For developer guidance, see the icon property of UNNotificationAction.

Badging / 角标

You can badge your app icon to indicate a count of unread notifications. For developer guidance, see applicationIconBadgeNumber.

   开发者可通过标记 app 图标来指出未读通知的数量。

Use a badge only to show people how many unread notifications they have. Don’t use a badge to convey other types of numeric information, such as weather-related data, dates and times, stock prices, or game scores.

   角标只用于向用户显示其有多少未读通知。不要通过使用角标来传达其他类型的数字信息(例如:与天气相关的数据、日期、时间、股票价格、游戏分数。

Don’t use a badge to communicate important information. People can turn off badging for your app, so if you rely on badging to communicate important information, you run the risk of people missing it.

   不要通过使用角标来传达重要信息。用户可能会关闭 app 角标,所以如果开发者依靠角标来传达重要信息,则开发者会冒着用户错过该重要信息的风险。

Keep badges up to date. Update your app’s badge as soon as people view the corresponding information. You don’t want people to think there’s new information available, only to find that they’ve already seen it. Note that reducing a badge’s count to zero removes all related notifications from Notification Center.

   保持角标最新。用户一看到相应信息就要更新 app 角标。开发者不想要让用户认为有可用的新信息,结果用户却发现已经看过这个信息了。注意:当角标数量减少到 0 时,系统会将所有相关的通知从通知中心(Notification Center)中移除。

Sending Marketing Notifications / 发送营销通知

Don’t use notifications to send marketing or promotional content unless people explicitly agree to receive such information. When people want to learn about new features, content, or events related to your app, they can grant their permission to receive marketing notifications. For example, the users of a subscriptions app might appreciate getting an offer to become a subscriber, and the players of a game might want to receive a special offer related to a live event.

   除非用户明确同意接收此类信息,否则不要使用通知来发送营销或促销内容。当用户想要了解与 app 相关的新功能、内容、事件时,用户可通过授予权限来接收营销通知。例如:订阅 app 的用户可能会喜欢获得成为订阅者的优惠,游戏玩家可能想要收到与现场活动相关的特别优惠。

   IMPORTANT / 重要

Never designate a marketing notification as Time Sensitive. For guidance, see Helping People Manage Notifications.

   从不将营销通知指定为时间敏感。

Get people’s permission if you want to send them promotional or marketing notifications. Before you send these notifications to people, you must receive their explicit permission to do so. Create an alert, modal view, or other interface that describes the types of information you want to send and gives people a clear way to opt in or out.

   如果开发者想向用户发送促销或营销通知,则取得用户的权限。在向用户发送这些通知之前,开发者必须获得用户的明确权限才能这样做。创建警告、模式视图、其他描述开发者想要发送的信息类型的界面,并为用户提供选择加入或退出的明确方式。

Make sure people can manage their notification preferences within your app. In addition to requesting permission to send informational or marketing notifications, you must also provide an in-app settings screen that lets people change their choice. For guidance, see Settings.

   确保用户可在 app 中管理其通知首选项。除了请求发送信息或营销通知的权限之外,开发者还必须提供让用户更改其选择的 app 内设置屏。

4.5.3

   

   原文地址:https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/notifications/

   

下一章:4.5 Printing / 打印


控件集——Badge/通知徽标/小红点/Notice point

   在开始之前,我们先来追溯一下小红点的起源。小红点到底是由谁最先发明的呢?众说纷纭,其中一个比较受大众认同的说法是,小红点最早来自于黑莓手机系统。在诺基亚仍一统天下的时代,新消息的提醒为图标+数字的形式,更像是Web端的处理方式。黑莓在2009年推出的9700系列,其搭载的黑莓系统开始使用了带星号的小红点形式。

而在小红点的专利归属上,Apple公司成为了最终赢家。Apple公司于2013年注册了相关专利,并在iOS系统上开始正式使用,小红点由此逐渐被人们所熟知。

在iOS界面设计指南中,Apple公司对涉及小红点的推送通知规范也有明确的阐述:

无论设备被锁屏还是在使用中,app都能随时利用通知来提供及时和重要的信息。每个通知都包含应用名称、一个app图标以及一条消息。通知的到来也可能伴随声音提示,以及app图标右上角小红点角标的出现和更新。Android随后跟进模仿了这一设计样式,小红点成为了通用设计的规范。如今,小红点的身影在各个App中几乎无处不在,在移动互联网的时代,它与我们的日常生活正变得密不可分起来。

“通知用的红点”是目前人们普遍对于它的称呼,其实其正式的名称为「Badge」(徽标),Badge 指出现在应用程序图标(APP Icon),自定义图标(Custom Icon) 右上角、栏右侧的红色圆点或环形,是意符的一种。有内部带有数字,和内部带有文字两种衍生形式。
1、圆点+数字

通知徽标最早出现在手机系统的 UI规范中,在应用程序收到新的消息、或有新的通知时出现。出现形式以红点中包含一个数字为主。后来例如微信等应用程序参照了该规范,用于消息数量的显示。其优势在于可以使用户第一时间了解什么位置发生了什么事件,发生了几个事件,协助用户做决定。

2、圆点

只需让用户了解有更新或新内容必然只有一条时,使用无数字Badge,例如微信公众号更新和App版本更新采用无数字类型。

圆点+数字的降级用法,目的是不抢其主要视觉重点的同时起到提醒的作用。例如微信的消息免打扰等次级消息提醒。

3、圆点+文字

大部分用于app 中金刚区的新功能介绍。起到简炼、痛点的作用。
1、是否显示徽标

交互设计应当通过用户决定是否显示徽标。

2、徽标形状

徽标形状通常以正椭圆形或环形表达。也有其衍生设计,如下图所示:

3、封顶长度

   由于界面显示空间有限,因此要注意:

· 视场景和信息类型决定数字最长显示多少位;

· 如果数字达到上限该怎样显示;(可选值为overflow、ellipsis、limit,默认值为overflow)

· 通常情况下有三种封顶数字的表达形式。一个是封顶数字为99,后面跟“+”(overflow);一个是显示省略号(ellipsis);一个是以千为计数,在数字后面跟“k”(limit)。

4、自定义的徽标内容

通常情况下自定义的徽标内容分为文字和 icon。当徽标内显示内容为文字时,通常不会超过6个字符长度,当徽标内显示内容为 icon 时,通常为 icon 规范中可视范围内的最小尺寸。

5、映射导向

每当一项业务有新的动态消息或上新的内容时,都要在业务入口处投放小红点以把用户引导到最终页面,但投放的小红点往往会出现断层的情况,用户在一步步轻触到达最终的页面后戛然而止,不清楚产品侧想给他展示什么内容。

应用程序上的通知徽标,当用户点开时,会出现在应用程序中相应的第一层级页面自定义图标上。思考每一个层级业务入口投放小红点的合理性,如此一来每个页面层级的小红点也能继承起来,给用户以清晰的映射导向。
谨慎在图标内运用红色圆点元素

红色小圆点这个视觉元素已经成为一种社会性语义符号,即用户看到红色小圆点就会认为这代表着有新内容,投放太多小红点容易产生两种极端情况,一个是造成用户产生厌烦心理而卸载App,另一个是用户对小红点完全产生免疫,尤其是在游戏App中,试问你现在玩王者荣耀的时候,面对满屏的小红点,还要每次都全部消除完毕之后才会开黑吗。

另外,如果一个页面中徽标使用过多会让用户产生眼花缭乱的负面体验 。 因此,在投放小红点之前,先思考一下在某一入口投放小红点的目的,到底什么是我们想让用户第一时间看到的?为此我们应该省略些什么?怎样去做好一个页面的整体视觉关系?是不是有其他更好的方式能代替小红点,即符合业务场景又能起到为业务导流的作用。
徽标虽然已经是一种语义符号铭刻于用户的心智模型之中,但我们依然不能利用这一点,在界面中布满徽标这种元素,迫使用户查看他们不感兴趣的内容。另外,在使用徽标时必须做好映射,以此避免点击进入一个带有徽标的页面时不知道什么才是下一步的操作。

Android应用图标上的小红点Badge亲自实践

   现在Android中有许多的应用仿苹果的在应用图标上显示小红点。当然有着一些手机ROM对小红点的支持,比如小米,三星等。google的api是没有提供这项工能的,这项功能一般都是厂商自己定制的,所以让开发者着实头痛,我也是弄了2天,不是所有的机型都可以.以后再一点点完善吧.希望对读文章的人,或也在受此困惑的人有点帮助!

效果图:(DODO那个是我的应用,小米miui8测试)

   直接上代码吧,代码中有注释:

   BadgeUtil类:


   public class BadgeUtil { private BadgeUtil() throws InstantiationException { throw new InstantiationException("This class is not for instantiation"); } /** * 设置Badge 目前支持Launcher */ public static void setBadgeCount(Context context, int count, int iconResId) { if (count <= 0) { count = 0; } else { count = Math.max(0, Math.min(count, 99)); } if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) { setBadgeOfMIUI(context, count, iconResId); } else if (Build.MANUFACTURER.equalsIgnoreCase("sony")) { setBadgeOfSony(context, count); } else if (Build.MANUFACTURER.toLowerCase().contains("samsung") || Build.MANUFACTURER.toLowerCase().contains("lg")) { setBadgeOfSumsung(context, count); } else if (Build.MANUFACTURER.toLowerCase().contains("htc")) { setBadgeOfHTC(context, count); } else if (Build.MANUFACTURER.toLowerCase().contains("nova")) { setBadgeOfNova(context, count); }else if (Build.MANUFACTURER.toLowerCase().contains("OPPO")) {//oppo //setBadgeOfOPPO(context, count); }else if (Build.MANUFACTURER.toLowerCase().contains("LeMobile")) {//乐视 } else if (Build.MANUFACTURER.toLowerCase().contains("vivo")) { setBadgeOfVIVO(context, count); }else if (Build.MANUFACTURER.toLowerCase().contains("HUAWEI")||Build.BRAND.equals("Huawei")||Build.BRAND.equals("HONOR")) {//华为 setHuaweiBadge(context, count); }else if (Build.MANUFACTURER.toLowerCase().contains("")) {//魅族 }else if (Build.MANUFACTURER.toLowerCase().contains("")) {//金立 }else if (Build.MANUFACTURER.toLowerCase().contains("")) {//锤子 }else { //Toast.makeText(context, "Not Found Support Launcher", Toast.LENGTH_LONG).show(); } } /** * 设置MIUI的Badge */ private static void setBadgeOfMIUI(Context context, int count, int iconResId) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setContentTitle("标题").setContentText("消息正文").setSmallIcon(iconResId); Notification notification = builder.build(); try { Field field = notification.getClass().getDeclaredField("extraNotification"); Object extraNotification = field.get(notification); Method method = extraNotification.getClass().getDeclaredMethod("setMessageCount", int.class); method.invoke(extraNotification, count); } catch (Exception e) { e.printStackTrace(); } mNotificationManager.notify(0, notification); } /** * 设置索尼的Badge * 需添加权限:<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" /> */ private static void setBadgeOfSony(Context context, int count) { String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return; } boolean isShow = true; if (count == 0) { isShow = false; } Intent localIntent = new Intent(); localIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE"); localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", isShow);//是否显示 localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", launcherClassName);//启动页 localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(count));//数字 localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName());//包名 context.sendBroadcast(localIntent); } /** * 设置三星的Badge设置LG的Badge */ private static void setBadgeOfSumsung(Context context, int count) { // 获取你当前的应用 String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return; } Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE"); intent.putExtra("badge_count", count); intent.putExtra("badge_count_package_name", context.getPackageName()); intent.putExtra("badge_count_class_name", launcherClassName); context.sendBroadcast(intent); } /** * 设置HTC的Badge */ private static void setBadgeOfHTC(Context context, int count) { Intent intentNotification = new Intent("com.htc.launcher.action.SET_NOTIFICATION"); ComponentName localComponentName = new ComponentName(context.getPackageName(), getLauncherClassName(context)); intentNotification.putExtra("com.htc.launcher.extra.COMPONENT", localComponentName.flattenToShortString()); intentNotification.putExtra("com.htc.launcher.extra.COUNT", count); context.sendBroadcast(intentNotification); Intent intentShortcut = new Intent("com.htc.launcher.action.UPDATE_SHORTCUT"); intentShortcut.putExtra("packagename", context.getPackageName()); intentShortcut.putExtra("count", count); context.sendBroadcast(intentShortcut); } /** * 设置Nova的Badge */ private static void setBadgeOfNova(Context context, int count) { ContentValues contentValues = new ContentValues(); contentValues.put("tag", context.getPackageName() + "/" + getLauncherClassName(context)); contentValues.put("count", count); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), contentValues); } /** * 设置vivo的Badge :vivoXplay5 vivo x7无效果 */ private static void setBadgeOfVIVO(Context context,int count){ try { Intent intent = new Intent("launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM"); intent.putExtra("packageName", context.getPackageName()); String launchClassName = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()).getComponent().getClassName(); intent.putExtra("className", launchClassName); intent.putExtra("notificationNum", count); context.sendBroadcast(intent); }catch (Exception e){ e.printStackTrace(); } } /** *设置oppo的Badge :oppo角标提醒目前只针对内部软件还有微信、QQ开放,其他的暂时无法提供 */ private static void setBadgeOfOPPO(Context context,int count){ try { Bundle extras = new Bundle(); extras.putInt("app_badge_count", count); context.getContentResolver().call(Uri.parse("content://com.android.badge/badge"), "setAppBadgeCount", String.valueOf(count), extras); } catch (Exception e) { e.printStackTrace(); } } /** * 设置华为的Badge :mate8 和华为 p7,honor畅玩系列可以,honor6plus 无效果 */ public static void setHuaweiBadge(Context context, int count) { try { Bundle bundle = new Bundle(); bundle.putString("package", context.getPackageName()); String launchClassName = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()).getComponent().getClassName(); bundle.putString("class", launchClassName); bundle.putInt("badgenumber", count); context.getContentResolver().call(Uri.parse("content://com.huawei.android.launcher.settings/badge/"), "change_badge", null, bundle); } catch (Exception e) { e.printStackTrace(); } } public static void setBadgeOfMadMode(Context context, int count, String packageName, String className) { Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE"); intent.putExtra("badge_count", count); intent.putExtra("badge_count_package_name", packageName); intent.putExtra("badge_count_class_name", className); context.sendBroadcast(intent); } /** * 重置Badge */ public static void resetBadgeCount(Context context, int iconResId) { setBadgeCount(context, 0, iconResId); } public static String getLauncherClassName(Context context) { PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); ResolveInfo info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (info == null) { info = packageManager.resolveActivity(intent, 0); } return info.activityInfo.name; }}

appicon是什么意思

   名字分开,app是应用,icon是图标,没啥用的东东,可以删。整个意思就是上面说的应用程序的图标

发表评论

免责声明:本站部分内容转载于网络,其中内容仅代表作者个人观点,与本网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。

本站联系邮箱:douxingdu02@163.co m