3

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 :

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

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

  3. 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?

enter image description here

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?

Community
  • 1
  • 1
duggu
  • 37,851
  • 12
  • 116
  • 113
  • how did you add the badge? if the app has never run, after being reinstalled, you don't get any notification until its run for the first time, so you can't clear the badge. I have the same problem with iOS. The idea here is, that the user doesnt often uninstall/reinstall like a developer does – Lena Bru Jun 05 '14 at 09:00
  • is this your app? The "Badges" could be data the app is using, stored on an SD card somewhere. It means something. Your question is very hard to understand. – IAmGroot Jun 05 '14 at 09:00
  • @Doomsknight he means that when he put up the badge, then uninstalled, then reinstalled, the app should be "clean" but the badge appears – Lena Bru Jun 05 '14 at 09:01
  • @LenaBru yes you right – duggu Jun 05 '14 at 09:03
  • @LenaBru The badge being the number 6 in the example picture ? It may not be app persistent data (which gets removed on uninstall), but file persistent data. – IAmGroot Jun 05 '14 at 09:03
  • Te data which you are using for adding on badges, is not being removed once saved. So, on fresh install you must check for it. If it exists, delte/clear these values/data/files. – Kanak Sony Jun 05 '14 at 09:03
  • 1
    google play does not give any notification on "fresh install" as far as i know. do you know otherwise ? – Lena Bru Jun 05 '14 at 09:04
  • You can store in Shared Prefs, whether the app has been run before or not. – IAmGroot Jun 05 '14 at 09:06
  • @Doomsknight when you reinstall the app over an existing app. If the app has not run yet. the previous state will remain. but the app wont be able to do anything about it – Lena Bru Jun 05 '14 at 09:13
  • @Golu how did you display the badge? – Lena Bru Jun 05 '14 at 09:14
  • Thats updating the app.. not re-installing ( Uninstall -> install ) So is not an issue – IAmGroot Jun 05 '14 at 09:14
  • i just uninstall app and install again @Doomsknight – duggu Jun 05 '14 at 09:27
  • @Doomsknight can u elaborate more is not an issue? – duggu Jun 05 '14 at 09:32
  • You Must be storing the Badge counter somewhere.. Delete this counter... Use shared prefs to determine if its the first time app is run since installation, to know when to delete the counter. – IAmGroot Jun 05 '14 at 11:22
  • @Doomsknight showing badges when call api and if badges greater then zero then i have show badges. – duggu Jun 05 '14 at 12:25

1 Answers1

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

Community
  • 1
  • 1
IAmGroot
  • 13,760
  • 18
  • 84
  • 154
  • already use this method but above method works fine if user open application in same time. If user done and going to home screen then showing badges. – duggu Jun 06 '14 at 06:11