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
Highlighted
New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea
Accepted Solution

notification icon and descriptor on home screen like push notification


hi i am new to blackberry development i want to ask that how can i show notification on home screen with app icon and some notification text(description)..plz give some sample...i already tried
try
{
EncodedImage icon = EncodedImage.getEncodedImageResource("icon1.png");

// create an application icon with the given image.
ApplicationIcon newIcon = new ApplicationIcon(icon);

// get an instance of Application Indicator Registry
ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance();

ApplicationIndicator appIndicator = reg.register(newIcon, false, true);

appIndicator.setIcon(newIcon);

appIndicator.setVisible(true);
}
catch (Exception ex) {
}
but its not working i am developing for blackberry os6

Contributor
Posts: 49
Registered: ‎12-29-2011
My Device: 9800
My Carrier: vodafone

Re: notification icon and descriptor on home screen like push notification

Hello,

Please refer this link , it will definitely help you:

http://supportforums.blackberry.com/t5/Java-Development/Application-Indicators-and-Home-Screen-Integ...

Also, please have a look on MessageListDemo comes under your testing tools.


Thanks,
New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea

Re: notification icon and descriptor on home screen like push notification

hey but i am getting null exception at 

 ApplicationIndicator indicator = reg.register(mIcon, false, true);

please any idea

Contributor
Posts: 49
Registered: ‎12-29-2011
My Device: 9800
My Carrier: vodafone

Re: notification icon and descriptor on home screen like push notification

ApplicationIndicator register(ApplicationIcon icon,
boolean iconOnly,
boolean visible)
Registers an application indicator with given icon.
It gives NullPointerException - if icon is null .
so please check whether you placed your icon in resource img folder or not.
New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea

Re: notification icon and descriptor on home screen like push notification

yes i already put image in res/img folder and also tried with putting it directly in res folder any other way i can try?

Contributor
Posts: 49
Registered: ‎12-29-2011
My Device: 9800
My Carrier: vodafone

Re: notification icon and descriptor on home screen like push notification

then paste some code snippet so that it will be easy to understand how and where you are putting these
lines.
New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea

Re: notification icon and descriptor on home screen like push notification

is my code

 

 

public static void registerIndicator() {

      

      ApplicationIcon mIcon =null;

      ApplicationIndicatorRegistry reg=null;

      try{

        EncodedImage mImageGreen = EncodedImage.getEncodedImageResource("icon.png");

        ApplicationIcon mIconGreen = new ApplicationIcon(mImageGreen);

         mIcon = mIconGreen;

      

            reg = ApplicationIndicatorRegistry.getInstance();

     

            ApplicationIndicator indicator = reg.register(mIcon, false, true);

            indicator.setVisible(true);

      } catch (Exception ex) { 

    //  if(mi)

            Dialog.inform("Error registration "+ex.toString());

            }

           // 

      

    }

 

public static void updateIndicatorValue(int value) {

 

    try {

        ApplicationIndicatorRegistry reg = ApplicationIndicatorRegistry.getInstance(); 

        ApplicationIndicator appIndicator = reg.getApplicationIndicator(); 

        appIndicator.setValue(value); 

        appIndicator.setVisible(true);

    } catch (Exception e) { }

}

Contributor
Posts: 49
Registered: ‎12-29-2011
My Device: 9800
My Carrier: vodafone

Re: notification icon and descriptor on home screen like push notification

First, I don't know why you are not able to get the notification icon on home screen as i checked your code and it is working. Although modified some where

private void rsgiseterIndicator() {
ApplicationIndicatorRegistry reg=null;
try{
EncodedImage mImageGreen = EncodedImage.getEncodedImageResource("icon.png");
ApplicationIcon mIconGreen = new ApplicationIcon(mImageGreen);
reg = ApplicationIndicatorRegistry.getInstance();

ApplicationIndicator indicator = reg.register(mIconGreen, false, true);
indicator.setIcon(mIconGreen);
indicator.setVisible(true);
} catch (Exception ex) {
Dialog.inform("Error registration "+ex.toString());
}
}

public static void updateIndicatorValue(int value) {
try {
ApplicationIndicator _indicator = ApplicationIndicatorRegistry.getInstance().getApplicationIndicator();
_indicator.setValue(_indicator.getValue() + value);
if(_indicator.getValue() <= 0)
{
_indicator.setVisible(false);
}
else
{
_indicator.setVisible(true);
}
} catch (Exception e) { }
}
secondly, you can get the notification icon from this code not the summary or description as you want. To achieve that you have to register for your own app message folder.

I strongly recommend you to import BB sample MessageListDemo. It is same as per your requirement.

Thanks,
New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea

Re: notification icon and descriptor on home screen like push notification

thanks for ur reply and i am able to show message list only problem is the notification icon i will check your code and get back to u ..thanks for ur help friend

New Developer
Posts: 32
Registered: ‎05-05-2014
My Device: 9780
My Carrier: Idea

Re: notification icon and descriptor on home screen like push notification

[ Edited ]

hey thanks for your help dear and i solved my problem .the problem was the icon size if icon size is more than 24*24 it throws an exception ..thanks once again