简体   繁体   English

如何以编程方式在主屏幕应用程序图标android中设置徽章编号?

[英]How set badge number in home screen app icon android programatically?

I would like create app with custom badge number in app icon, like in facebook app: App icon in home screen shows pending/unread notifications. 我想在应用程序图标中创建带有自定义徽章编号的应用程序,就像在Facebook应用程序中一样:主屏幕中的应用程序图标显示待处理/未读通知。 How to set custom badge number programatically in android. 如何在Android中以编程方式设置自定义徽章编号。 I've seen similar questions in stack with answers like it "doesn't support in stock android". 我已经在堆栈中看到了类似的问题,并给出了类似的答案:“不支持股票android”。 Seen many answers and were old. 看过很多答案,而且很老。 I think they were for old versions. 我认为它们适用于旧版本。 Is it possible in newer versions of android? 在较新的android版本中可以吗? If possible how to add customized badge number ? 如果可能,如何添加自定义的徽章编号? If the option is still doesn't support by android ignore this question and please let me know it. 如果该选项仍然不受Android支持,请忽略此问题,并让我知道。 I'm developing kind of confidential app, so that i couldn't use third part libs. 我正在开发一种机密应用程序,因此我不能使用第三方库。 Is there any inbuilt methods to handle badges or possible to create badge? 是否有任何内置方法来处理徽章或可以创建徽章?

There is popular github that works app icon badges for most Android devices. 有一个流行的github,适用于大多数Android设备的应用程序图标徽章。 Sure still some platform, some devices didn't support that. 当然,仍然有一些平台,某些设备不支持该平台。 But those libraries almost cover all of the devices that support app icon badges. 但是这些库几乎涵盖了所有支持应用程序图标徽章的设备。

https://github.com/leolin310148/ShortcutBadger https://github.com/leolin310148/ShortcutBadger

So to your question, No. Because Android framework didn't define the app notification badges before.(I am not sure if Android default framework have it now. I've been search the keyword of BADGE_COUNT_UPDATE in the ASOP android7 and nothing found) So all those custom badges are made by device manufacturer framework developer. 因此,对您的问题,不是。因为Android框架以前没有定义应用程序通知徽章。(我不确定Android默认框架现在是否具有它。我一直在ASOP android7中搜索BADGE_COUNT_UPDATE的关键字,但未找到任何内容)因此,所有这些自定义徽章都是由设备制造商框架开发人员制作的。

You can check how they setup badges numbers for each manufacturer here 您可以在此处查看他们如何为每个制造商设置徽章编号

https://github.com/leolin310148/ShortcutBadger/tree/master/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/impl https://github.com/leolin310148/ShortcutBadger/tree/master/ShortcutBadger/src/main/java/me/leolin/shortcutbadger/impl

To another question. 另一个问题。 I use keyword badge to search the ASOP source code and didn't find any noticeable part about app icon badges. 我使用关键字badge来搜索ASOP源代码,但未找到有关应用程序图标badge的任何明显部分。 And even there is one inbuilt framework method about this after certain version of android. 在某些版本的android之后,甚至还有一个内置的框架方法。 The framework still cannot cover all the devices before the certain version. 该框架仍然无法覆盖特定版本之前的所有设备。 So not quite sure what do you mean by confidential app , but using libraries is the first choice to cover most android devices based on the real situation like this. 因此,不太确定您所说的“ 机密应用”是什么意思,但基于这样的实际情况,使用库是覆盖大多数android设备的首选。

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

相关问题 以编程方式安装Android应用程序时如何在主屏幕上添加图标? - How to add a icon on home screen while installing an android app programatically? Android 主屏幕应用程序图标与不需要的迷你图标徽章 - Android Home Screen App Icon With Unwanted Mini-Icon Badge 我们如何在Android中以编程方式为“锁定屏幕通知和徽章图标”等应用启用通知设置 - How can we enable notification setting in android for app like “lock screen notification and badge icon” programatically 如何以编程方式在应用程序图标上设置徽章? - How to set badge on app icon programmatically? 如何在应用程序图标上设置通知徽章 - How to set notifications badge over app icon 如何在Android的主屏幕上的我的应用程序图标上显示通知计数 - How to show Notification Count on My App Icon on Home Screen in Android 如何在主屏幕 android 上添加应用程序图标(react-native)? - How to add icon of the app on the home android screen (react-native)? 如何以编程方式进入Android的默认主屏幕? - How to go to the default home screen of Android programatically? 科尔多瓦android应用程序不显示主屏幕上的图标 - Cordova android app not showing icon on home screen 使用LauncherShortcuts在主屏幕上显示Android App图标 - Android App Icon on Home Screen using LauncherShortcuts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM