在android中清除数据和卸载应用程序后如何清除计数徽章? [英] How to clear count badge after clearing data and uninstall application in android?

查看:42
本文介绍了在android中清除数据和卸载应用程序后如何清除计数徽章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是当我安装应用程序并使用它时,它在应用程序图标上显示计数标记.现在,当我卸载应用程序(应用程序图标上显示计数徽章时)并重新安装应用程序时,它再次在应用程序图标上显示徽章计数.

The problem is when I install application and use it, it shows count badge on application icon. Now when I un-install application (while count badge is being displayed on application icon), and re-install the application, it again shows badge count on application icon.

(注意:-它显示的是卸载应用程序时的最后一个徽章计数)

我的问题是:

  1. 为什么重新安装应用程序后会显示徽章计数?

  1. Why badge count is being displayed after re-installing application?

卸载应用程序不会清除其全部数据吗?

Do un-installing an application not clear its whole data?

我可以在卸载应用程序时清除徽章计数吗?

Can I clear the badge count when I un-install the application?

如果它不可能,那么任何人都可以给我任何相同的链接吗?

If its not possible, then can anybody provide me any link for the same?

我借助以下链接整合了徽章计数:-

I integrated badge count with the help of the following link:-

如何与三星手机上的 BadgeProvider 接口来为应用图标添加计数?

推荐答案

您链接的问题/答案实际上有关于如何清除徽章的答案.

The question/answer you link actually has the answer on how to clear badges.

ContentValues cv = new ContentValues();
cv.put("badgecount", 0);
getContentResolver().update(Uri.parse("content://com.sec.badge/apps"), cv, "package=?", new String[] {getPackageName()});  

https://stackoverflow.com/a/20136484/940834

因此只需适当调用此方法即可清除徽章.

So just call this method appropriately to clear the badge.

例如,检查自全新安装后是否首次加载应用程序,然后应用.

For example, check if first time loading app since fresh install, then apply.

  // CHECK IF FIRST LOAD
  if(!PreferenceManager.getDefaultSharedPreferences(this).contains("NOTFIRSTLOAD"))
 {
       ContentValues cv = new ContentValues();
       cv.put("badgecount", 0);
       getContentResolver().update(Uri.parse("content://com.sec.badge/apps"), cv, "package=?", new String[] {getPackageName()});  

       // Store that its not first load 
       PreferenceManager.getDefaultSharedPreferences(this).edit().putInt("NOTFIRSTLOAD", 1).commit();
  }

阅读原始问题/答案以获取更多信息

Read origional question/answer for more info

这篇关于在android中清除数据和卸载应用程序后如何清除计数徽章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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