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

Web and WebWorks Development

Reply
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile
Accepted Solution

Widget and banner notification

Is it possible to use a notification in the top section of the screen (banner) in the same way as email counters, facebook etc. from a widget? If so is there an API and some sample code?

 

Thanks,

Please use plain text.
Developer
agungeddy
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Widget and banner notification

[ Edited ]

yes it is possible, see this forum thread as one of the reference:

 

http://supportforums.blackberry.com/t5/Web-Development/Change-icon-when-receive-new-push-data-from-B...

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Widget and banner notification

OK after trying to work through this sample code, still no success. Can anyone share a working jar file? This way I can see what I am missing, because right now I can't see anything different from the sample code.

 

Thanks

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Widget and banner notification

I know one of our Developer Relations folks made one.. I can see if he can fork the github repository and push up his code.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
agungeddy
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Widget and banner notification

[ Edited ]

 


csibbdev wrote:

OK after trying to work through this sample code, still no success. Can anyone share a working jar file? This way I can see what I am missing, because right now I can't see anything different from the sample code.

 

Thanks


Maybe you can show or even upload your codes here, so the other developers here can see any missing and errors in your codes...

 

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Widget and banner notification

OK here we go - it appears to run, that is it doesnt throw an error. Any help would be appreciated.

 

Thanks

 

package widgetpackage;

import net.rim.device.api.script.Scriptable;

public final class UpdatePhone extends Scriptable {	

	public static final String FIELD_CHANGEICON = "changeicon";
	private ChangeIcon changer;
	
	public UpdatePhone(){		
		this.changer = new ChangeIcon();	
	}
	
	public Object getField(String name) throws Exception {					
			
		if (name.equals(FIELD_CHANGEICON)) 
		{
			return this.changer;
		}
		
			return super.getField(name);
	}

}

 

package widgetpackage;

import net.rim.device.api.script.ScriptableFunction;
import net.rim.blackberry.api.messagelist.ApplicationIcon;
import net.rim.blackberry.api.messagelist.ApplicationIndicator;
import net.rim.blackberry.api.messagelist.ApplicationIndicatorRegistry;
import net.rim.device.api.system.EncodedImage;




public final class ChangeIcon extends ScriptableFunction {    
    
    public Object invoke(Object obj, Object[] args) throws Exception
    {
    	try {
    	EncodedImage mImageGreen = EncodedImage.getEncodedImageResource("Warning.png");
    	ApplicationIcon mIconGreen = new ApplicationIcon(mImageGreen);
    			
    	ApplicationIcon mIcon = mIconGreen;

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

    	catch(Exception e) {
        	e.printStackTrace();
        }
        
        return UNDEFINED;
    }

}

 

package widgetpackage;

import org.w3c.dom.Document;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.script.ScriptEngine;
import net.rim.device.api.web.WidgetConfig;
import net.rim.device.api.web.WidgetExtension;

public final class EspressoExtension implements WidgetExtension {

    public String[] getFeatureList() {
        
        String[] result = new String[1];
        result[0] = "espresso";
        return result;
    }

    public void loadFeature(String feature, String version, Document doc,
            ScriptEngine scriptEngine) throws Exception {
        
        if (feature == "espresso") {
            scriptEngine.addExtension("espresso.homescreen", new UpdatePhone());
            }

    }

    public void register(WidgetConfig arg0, BrowserField arg1) {
        // TODO Auto-generated method stub

    }

    public void unloadFeatures(Document arg0) {
        // TODO Auto-generated method stub

    }

}

 

<?xml version="1.0" encoding="UTF-8"?>
<library>
<extension>
<entryClass>widgetpackage.EspressoExtension</entryClass>
</extension>
<features>
<feature id="espresso" version="1.0.0" >Charter Solutions LLC BB Notifier JavaScript extension</feature>
</features>
</library>

 

Please use plain text.
Developer
agungeddy
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Widget and banner notification

[ Edited ]

I have just already tested your java codes above, and they are working fine, the icon image appeared normally in the device screen like you want.

 

So i think there are some possibilities about your problem:

 

1. Some mistakes in your config.xml (you didn't show your config.xml file above)

2. Some mistakes inside your content file to call the JS Extension (you also didn't give the example of the JavaScript to call it).

3. You haven't yet include the image icon inside the JAR file.

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Widget and banner notification

The javascript call

try {
   espresso.homescreen.changeicon;
   sample.alert.vibrate(1000); //This works
   }
   catch (Error) {
   alert(Error);
   }

 

 

The config file

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.8.27" rim:header="RIM-Widget:rim/widget" xmlns="http://www.w3.org/ns/widgets">
  <rim:navigation mode="focus" />
  <name>xxxx</name>
  <description>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</description>
  <author href="www.xxxxxxxxxxxxxxxxxxxt.com" rim:copyright="" email="info@xxxxxxxxxxxxxxxxxxxxxxxx.com">CSI</author>
  <icon src="Images\icon.png" />
  <content src="index.htm" />
  <feature id="blackberry.push" required="true" version="1.0.0.0" />
  <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
  <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
  <feature id="blackberry.app" required="true" version="1.0.0.0" />
  <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
  <feature id="blackberry.utils" required="true" version="1.0.0.0" />
  <feature id="blackberry.identity" required="true" version="1.0.0.0" />
  <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
  <feature id="blackberry.system" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
  <feature id="sample.alert" required="true" version="1.0.0.0" />
  <feature id="blackberry.find" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.MapsArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.MessageArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.MemoArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.PhoneArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.SearchArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke.TaskArguments" required="true" version="1.0.0.0" />
  <feature id="blackberry.message" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.category" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Memo" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Task" required="true" version="1.0.0.0" />
  <feature id="blackberry.system.event" required="true" version="1.0.0.0" />
  <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" />
  <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0" />
  <access uri="http://pushapi.eval.blackberry.com" subdomains="true">
    <feature id="blackberry.app" required="true" version="1.0.0.0" />
    <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
    <feature id="blackberry.utils" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0" />
    <feature id="blackberry.push" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
    <feature id="blackberry.system" required="true" version="1.0.0.0" />
  </access>
  <access uri="http://www.blackberry.com" subdomains="true" />
  <access uri="https://pushapi.eval.blackberry.com" subdomains="true" />
  <access uri="http://www.xxxxxxxxxxxxxxxxxxxxx.com" subdomains="true" />
  <access uri="http://www.xxxxxxxxxxxxxxxxxxx.com" subdomains="true" />
  <access uri="http://www.xxxxxxxxxxxx.net" subdomains="true">
    <feature id="blackberry.app" required="true" version="1.0.0.0" />
    <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.find" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MapsArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MessageArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MemoArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.PhoneArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.SearchArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.TaskArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
    <feature id="blackberry.message" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.category" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Memo" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Task" required="true" version="1.0.0.0" />
    <feature id="blackberry.push" required="true" version="1.0.0.0" />
    <feature id="blackberry.system" required="true" version="1.0.0.0" />
    <feature id="blackberry.system.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
    <feature id="blackberry.utils" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0" />
  </access>
  <access uri="https://www.xxxxxxxxxxxxxxxxxxxxxxxx.net" subdomains="true">
    <feature id="blackberry.app" required="true" version="1.0.0.0" />
    <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.find" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MapsArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MessageArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MemoArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.PhoneArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.SearchArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.TaskArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
    <feature id="blackberry.message" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.category" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Memo" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Task" required="true" version="1.0.0.0" />
    <feature id="blackberry.push" required="true" version="1.0.0.0" />
    <feature id="blackberry.system" required="true" version="1.0.0.0" />
    <feature id="blackberry.system.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
    <feature id="blackberry.utils" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0" />
  </access>
  <access uri="http://maps.google.com/maps/api/geocode" subdomains="true" />
  <access uri="http://where.yahooapis.com/geocode" subdomains="true" />
  <access uri="http://code.google.com/apis/gears" subdomains="true" />
  <access uri="file:///store/home/user/pictures" subdomains="true">
    <feature id="blackberry.app" required="true" version="1.0.0.0" />
    <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.find" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity" required="true" version="1.0.0.0" />
    <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MapsArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MessageArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.MemoArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.PhoneArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.SearchArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.invoke.TaskArguments" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
    <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
    <feature id="blackberry.message" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.category" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Memo" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0" />
    <feature id="blackberry.pim.Task" required="true" version="1.0.0.0" />
    <feature id="blackberry.push" required="true" version="1.0.0.0" />
    <feature id="blackberry.system" required="true" version="1.0.0.0" />
    <feature id="blackberry.system.event" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
    <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
    <feature id="blackberry.utils" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache" required="true" version="1.0.0.0" />
    <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0" />
    <feature id="sample.alert" required="true" version="1.0.0.0" />
    <feature id="espresso" required="true" version="1.0.0.0" />
  </access>
  <rim:loadingScreen backgroundImage="Images\neutral_background_480_721.png" foregroundImage="Images\neutral_background_480_721.png" onRemotePageLoad="true" onLocalPageLoad="true" onFirstLaunch="true" />
  <rim:connection timeout="30000">
    <id>BIS-B</id>
    <id>MDS</id>
    <id>TCP_WIFI</id>
    <id>TCP_CELLULAR</id>
    <id>WAP2</id>
    <id>WAP</id>
  </rim:connection>
  <license href="" />
  <rim:cache disableAllCache="false" aggressiveCacheAge="2592000" maxCacheSizeTotal="1024" maxCacheSizeItem="-1" />
</widget>

 

 

 

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Widget and banner notification

Also for reference in the jar file the image called out in the java code is in the same directory structure as the java source files, for example,

 

 

library.xml

widgetpackage\ChangeIcon.java

                            \EspressoExtension.java

                            \Updatephone.java

                            \Warning.png

 

Thanks again for all your help on this.

 

Please use plain text.
Developer
agungeddy
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Widget and banner notification

[ Edited ]

1. I've just tested your codes again with using your pure config & javascript code above (no editing), your application throw the javascript catch error message: Reference Error: "espresso" is not defined

2. So i checked in config.xml , i noticed that the feature id="espresso" tag was inside the access uri tag, so i tried to move the feature id="espresso" tag to the outside of the  access uri tag.

3. Then i tested to run the application again, there was no javascript error message anymore, but the icon notification was still not apperared.

4. I continued by checked the javascript in your html content file, i edited your javascript codes to be like this:

try {
espresso.homescreen.changeicon();
sample.alert.vibrate(1000); //This works
}
catch (Error) {
alert(Error);
}

Notice the diffrence in the above my edited javascript, i tested the application again, it works.

 

Please use plain text.