如何添加Facebook的证件号码上的应用程序图标的Andr​​oid? [英] How does Facebook add badge numbers on app icon in Android?

查看:122
本文介绍了如何添加Facebook的证件号码上的应用程序图标的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有几个Qs的这里问如果可能的徽章添加到Android应用程序,它们都结束了一个无答案...

I know there are several Qs here that ask if its possible to add badges to an android app and they all end up with a NO answer...

但不知何故,最近Facebook的测试版Android版<一个href="http://forums.androidcentral.com/samsung-galaxy-note-2/294458-iphone-style-notifications-badge-android-facebook-beta.html">seems做一些事情,至少看起来像徽章哪怕是不是技术上正是这么做的。

But somehow the latest Facebook beta version for Android seems to do something which at least look like a badge even if it is not technically exactly that.

在该帖子的评论者之一,说这是某种相关的TouchWiz。 和也在这里,他们提到它为S3的TouchWiz果冻豆插件的功能。

In that post one of the commenters says that it is somehow related to TouchWiz. And also here they mention it as a feature of the "S3 TouchWiz Jelly Bean Addon".

我仍然会在如何可以做到这一点和AP preciate信息,如果有一些API,用于这一点,我可以在我自己的应用程序使用(在适当的环境中运行时 - 即相同的设备,其中FB演示这种行为)?

I still would appreciate information on how does this can be done and if there is some API for this that I can use in my own app (when running in an appropriate environment - i.e. the same device where FB demonstrates this behavior) ?

推荐答案

我已经想通了,这是怎么了索尼的设备完成的。

I have figured out how this is done for Sony devices.

我的博客上讲述它<一个href="http://marcusforsberg.net/blog/android-how-to-add-a-notification-badge-to-app-icon-on-sony-xperia-devices/">here.我还发布了一个单独的SO问题,关于这个<一href="http://stackoverflow.com/questions/20216806/how-to-add-a-notification-badge-count-to-application-icon-on-sony-xperia-devices">here.

I've blogged about it here. I've also posted a seperate SO question about this here.

索尼设备使用一个类名为 BadgeReciever

Sony devices use a class named BadgeReciever.

  1. 声明 com.sonyericsson.home.permission.BROADCAST_BADGE 允许在你的manifest文件:

  1. Declare the com.sonyericsson.home.permission.BROADCAST_BADGE permission in your manifest file:

播出的意图 BadgeReceiver

Intent intent = new Intent();

intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", "com.yourdomain.yourapp.MainActivity");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "99");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", "com.yourdomain.yourapp");

sendBroadcast(intent);

  • 完成。一旦这个意图广播发射应显示在您的应用程序图标徽章。

  • Done. Once this Intent is broadcast the launcher should show a badge on your application icon.

    要删除的徽章一遍,只需发送一个新的广播,这次 SHOW_MESSAGE 设置为false:

    To remove the badge again, simply send a new broadcast, this time with SHOW_MESSAGE set to false:

    intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", false);
    

  • 我已经排除了我如何发现这个保留的回答简短的细节,但是这一切都可以在博客。可能是一个有趣的阅读的人。

    I've excluded details on how I found this to keep the answer short, but it's all available in the blog. Might be an interesting read for someone.

    这篇关于如何添加Facebook的证件号码上的应用程序图标的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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