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
Developer
Posts: 47
Registered: ‎11-11-2009
My Device: Not Specified
Accepted Solution

How to Create Separate Push Listener?

Dear BB Developers,

 

I am currently creating an application that will use 2 applications: 1 for the GUI and 1 application for the push listener (auto start and always run in the background, and I do not want the application icon appear in the ribbon). The background application will,

 

I've searched for some -what they say useful- articles, but I still have some questions on how to do that. So please don't refer me to such articles and I prefer to see some working code and good guide on how to do that from the start.

 

Article DB--00157  tells about how to create background app and UI app, but the code snippet is too few Smiley Sad I just don't understand what type of application should the background listener be.

 

The article said that we have to reference each application to each other. If I add the UI project to the listener build path, and the listener project to the UI project build path, it will be an error. And If I only add those projects to the project reference (in the project properties), I cannot create the reference in the code.

 

DB--00406 is about folder listener, and it is actually only one application. I don't like this idea, I really need 2 separate application Smiley Sad

Developer
Posts: 16,986
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to Create Separate Push Listener?

applications can communicate on different ways. the easiest way would be to send global events.

you can create your pushlistener as an own application and start it in an autostart entry point of your app.

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/How_To_-_Setup_an_alternate_entry_point...

 

send a global event to your UI app (which has to implement GlobalEventListener and add itself as a listener).

 

if global events offer too few possibilities you can also use 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
Developer
Posts: 47
Registered: ‎11-11-2009
My Device: Not Specified

Re: How to Create Separate Push Listener?

Any links about that thing called 'Global Events'? Any code snippet?

 

i see, so the background application auto-start is configured in the project properties. And how do the background application calls the GUI application? How do they reference the UI application?

 

I still don't get it how I should do this.

Developer
Posts: 16,986
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to Create Separate Push Listener?

to communicate using global events you first device a long as a GUID. in the jde/ejde there is a tool to convert strings to longs, usually you use the package name + the event name.

 

to send a global event you use  the applicationmanager.

there are several methods that allow you to add a payload:

 

    ApplicationManager.getApplicationManager().postGlobalEvent(MY_GUID);

 

in your UI application implement GlobalEventListener and use this code:

addGlobalEventListener

 

 

in the eventOccured method you get the GUID of the occured event, check if it is MY_GUID and do your processing

 

----------------------------------------------------------
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
Developer
Posts: 47
Registered: ‎11-11-2009
My Device: Not Specified

Re: How to Create Separate Push Listener?

I will try your solution, and will ask again if I ever stuck again. If everything ok I will mark this problem as solved.

 

 

Thank you very much for your assistance Smiley Happy

Developer
Posts: 47
Registered: ‎11-11-2009
My Device: Not Specified

Re: How to Create Separate Push Listener?

Dear Simon,

 

Still got some more questions:

1. If both of the application has been finished, how to deploy them as one installer anyway? So when people want to install my application, they don't have to install twice Smiley Sad

 

2. I am still not sure about the advantages of having separate push listener application. Can someone show me what makes it better?

Developer
Posts: 16,986
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to Create Separate Push Listener?

depends on your use-case if you want separate apps or not.

you can use alternate entry points to have more than one app in one application.

or you can distribute multiple cods with one alx or jad.

----------------------------------------------------------
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