所有移动制造商的启动器图标上的 Android 徽章编号 [英] Android Badge number on launcher icon for all mobile manufacturer

查看:57
本文介绍了所有移动制造商的启动器图标上的 Android 徽章编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序启动器图标上需要一个徽章计数器.

I need a badge counter on my application launcher icon.

我知道使用 TextView 在应用程序内部获取徽章计数器的解决方案,但我需要一个解决方案来在启动器图标上获取应用程序外部的徽章计数器.

I know the solution to get Badge counter inside the app, using TextView, But I need a solution to get the badge counter external to the app on the launcher icon.

在 iOS 中,我们通过以下方式获得徽章数量

In iOS we get the badge number count by

UIApplication.sharedApplication().applicationIconBadgeNumber

我想知道为什么 Android 没有在他们的 SDK 中包含每个开发人员都需要的东西.

I am wondering why Android has not included anything like this with their SDK which every developer need.

尝试 1:仅适用于索尼手机:

Try 1 : Working only on sony mobiiles :

    Intent badgeIntent = new Intent();
    badgeIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", this.getPackageName());
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", this.getClass().getName());
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", ShwMsgBulVar);
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "10");

     context.sendBroadcast(badgeIntent);

<小时>

尝试2:我试过图书馆:https://github.com/leolin310148/ShortcutBadger

它只适用于少数制造商,并不适用于所有安卓手机.

It works only for few manufacturers and not common for all android mobiles.

ShortCutBadger 不适用于 OPPO、VIVO、Xiomi、Reliance LYF 默认启动器.

ShortCutBadger is not working on OPPO, VIVO, Xiomi, Reliance LYF default launchers.

经过一番研究,我了解到,徽章编号取决于发射器制造商,如下所示:

After couple of research, I came to know that, badge number depends on launcher manufacturer and listed as below :

ShortCutBadger 支持:

ShortCutBadger Suported :

  • 三星:com.sec.android.app.launcher"
  • 索尼:com.sonyericsson.home"
  • HTC:com.htc.launcher"
  • 华硕:com.asus.launcher"
  • 不支持 ShortCutBadger :

    ShortCutBadger not Suported :

    • OPPO :"com.oppo.launcher"
    • 小米:com.miui.home"
    • 体内:com.bbk.launcher2"
    • Lyf:com.android.launcher3"
    • 转到启动器:com.gau.go.launcherex"
    • 那么有没有其他通用的方法可以适用于所有制造商的手机?

      So is there any other general method which can work on all manufacturer mobiles?

      阅读了很多帖子并进行了大量搜索,但很多人表示没有适用于所有启动器的通用解决方案.
      但我觉得有一个解决方案,因为 whatsapp 和 facebook 应用程序在所有上述启动器中都显示了徽章编号.

      Read so many posts and did lot of search but Many tell there is no such generic solution which is applicable for all launchers.
      But I feel there is a solution because whatsapp and facebook app display the badge number in all the above mentioned launcher.

      推荐答案

      Android 中没有这样的功能,因为徽章编号不是平台的一部分.存在一些试图实现这一目标的库,例如 https://github.com/leolin310148/ShortcutBadger 但您应该明白它并不适用于每个制造商的设备.此外,据我所知,徽章只出现在主屏幕上的图标上,而不是在应用程序抽屉中.

      There is no such function in Android as badge numbers are not a part of the platform. A few libraries exist that try to achieve this such as https://github.com/leolin310148/ShortcutBadger but you should understand that it does not work for every manufacturer's device. Also as far as I understand the badges only appear over the icon when it is on a home screen and not in the app drawer.

      这篇关于所有移动制造商的启动器图标上的 Android 徽章编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆