【问题标题】:How to get a notification in the corner of program icon? [closed]如何在程序图标的角落获得通知? [关闭]
【发布时间】:2014-08-08 20:59:56
【问题描述】:

例如: 通知,如 facebook、未接来电和新消息通知。 我已在此处附上示例屏幕截图。

【问题讨论】:

  • 只是一个简单的猜测,收到通知后,只需更改图标:)
  • 您对此的实际要求是什么?
  • 你为什么点谷歌这个?
  • 您可以使用Application Widget Provider 存档。
  • @Simple Plan你能解释一下如何使用应用程序提供者来实现这一点吗?

标签: android push-notification icons


【解决方案1】:

没有通用的方法,我猜有一些制造商的私人扩展。因此,您可以挖掘特定于设备的 API,但它们也可能是私有的,最好放弃这个想法。

更新:但是对于三星设备是否有解决方案,请参阅this answer

【讨论】:

    【解决方案2】:

    在 android 中,我们没有 iOS 那样的徽章样式方法,但一些制造商支持在应用程序图标上显示徽章。

    Example for badge style icon on app in android

    三星、索尼、HTC 支持在应用图标上添加徽章。

    三星:

    ContentResolver localContentResolver = this.a.getContentResolver();
    Uri localUri = Uri.parse("content://com.sec.badge/apps");
    
    ContentValues localContentValues = new ContentValues();
    localContentValues.put("package", PACKAGE NAME);
    localContentValues.put("class", CLASS NAME);
    localContentValues.put("badgecount", number);
    
    update localContentResolver, if update fails then localContentResolver.insert(localUri, localContentValues);
    

    索尼

    Intent intent= new Intent("com.sonyericsson.home.action.UPDATE_BADGE");
    
    intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", Class Name);
    
    intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
    
    intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE",number);
    
    intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", packageName);
    
    sendBroadcast(intent);
    

    对于 HTC:

    Intent updateIntent = new Intent("com.htc.launcher.action.UPDATE_SHORTCUT");
    updateIntent.putExtra("packagename", packageName);
    updateIntent.putExtra("count", number);
    this.sendBroadcast(updateIntent);
    
    Intent setNotificationIntent = new Intent("com.htc.launcher.action.SET_NOTIFICATION");
    ComponentName localComponentName = new ComponentName(packageName, className);
    setNotificationIntent.putExtra("com.htc.launcher.extra.COMPONENT", localComponentName.flattenToShortString());
    setNotificationIntent.putExtra("com.htc.launcher.extra.COUNT", number);
    this.sendBroadcast(setNotificationIntent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-21
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多