问题
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.
(Note:- It iss showing last badge count when application was un-installed)
My problem is :
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:-
How to interface with the BadgeProvider on Samsung phones to add a count to the app icon?
回答1:
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
来源:https://stackoverflow.com/questions/24055413/how-to-clear-count-badge-after-clearing-data-and-uninstall-application-in-androi