Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011
My Device: Bold 9900
Accepted Solution

Forcing application Indicator to update

My application uses an application indicator (OS 7.0) however even though I can see the value is being correctly set, the count new to the icon does not update. 

 

The initial value is correctly set using this :

 

protected static void setIndicator(){
      int unreadCount = PersistentStorage.getUnreadMessageCount();
      EncodedImage image = EncodedImage.getEncodedImageResource("indicator.png");
     ApplicationIcon icon = new ApplicationIcon(image);
     ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance();
     indicator = reg.register(icon, false, true);
     indicator.setValue(unreadCount);
     indicator.setIcon(icon);
     indicator.setVisible(unreadCount>0);
}

 

Here is the update code:

 

public static void updateIndicator(final int value, boolean absolute) {
    // Update indicator
    final ApplicationIndicator indicator = ApplicationIndicatorRegistry.getInstance().getApplicationIndicator();
    if (indicator == null) {
         return;
    }

    if (absolute)
             indicator.setValue(value);
    else
             indicator.setValue(indicator.getValue() + value);
      indicator.setVisible(indicator.getValue()>0);
}

 

The code is always called as expected and the indicator value can be read back and is correct, just the value next to the indicator doesn't update. I would try to call Invalidate() on the indicator but doesn't any such function.

 

Any tip?

 

Thanks

 

Chris

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Forcing application Indicator to update

i suspect this being a problem of the static context and would suggest that you put the indicator into the runtimestore.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011
My Device: Bold 9900

Re: Forcing application Indicator to update

Thanks,   the static context was the issue. The silent API strikes again.

Please use plain text.