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

Regular Contributor
Posts: 59
Registered: ‎05-10-2012
My Device: 8800
My Carrier: verizon

ApplicationMenuItem/multiple entry points

[ Edited ]

Hello all


I want to add access to my app from the menu that appears when you hit Menu while having a contact highlighted.  In addition to access, I want to be albe to pass certain info from the contact entry to my app.


I understand I should be using ApplicationMenuItem but I'm unsure how to use it correctly.


First, how to I pass data from Contacts into my app when the menu item is selected?


Next, I want the menu item to appear whether or not my app is running.  How do I achieve that?  Should I require the app be always running?  Is having my app always running even a realistic possibility?


For now, I've got the call to ApplicationMenuItem in my app's constructor, however it ends up being executed multiple times because my app can be exited and restarted.  Every time the user exits and restarts my app, another menu item is added.  Enter/exit 5 times and you've got 5 of the same menu item appearing.  


How do I detect if I've already executed ApplicationMenuItem and prevent it from being executed more than once?

Additionally, reading the dev forum here, I've seen advice to use ApplicationMenuItem with  multiple entry points.  If my app is entered via the menu item I should detect that in main() and, if the app isn't already active, execute a special constructor that performs enough set up so my app can perform its function.  How do I set that up?


FWIW, I'm using Eclipse and the Blackberry plug in and would like this to operate on as many versions of the OS as possible.




Posts: 17,003
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: ApplicationMenuItem/multiple entry points

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/blackberry/api/menuitem/ApplicationMenuIt... should give you the desired menu item.
you (should) get the contact as a context object in the menu items run method.

the alternate entry point is a correct path, but rather to register the menu item. you can use it to set this part as autostart.

to hand the data to your application i suggest the following approach:
1. check if your application is running (using applicationmanager), if not, launch it.
2. send a global event containing the contact object

starting the application with the contact as a parameter is also possible, but may result in two instances (app running 2 times) as each entry point is a separate instance, for this reason we prefer the global event approach.
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