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
BeMor
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified

Launching application from context menu

I have an issue and can think of a number of work arounds but not sure on the cleanest solution.

 

We have a BB java application directory of people within our firm which is used to look up peoples telephone numbers and details whilst on the move. I wanted to add some new functionality to it by the way of context menus. So if you have a missed call from someone you can do a number lookup from the call log using a context menu option.

 

My issue is the best way to launch the application and what to do if it is already launched. My general thoughts are to add a global listener so to send out an event to close the currently running instance if there are any before launching a new one. My main worry is cleanly removing the global listener before exit or before the user exits to unsure no memory leaks. The other problem I have is how to pass the search criteria. If I do it as a launch parameter a different instance of the application is launched for each different set of parameters passed, concerning as need to make sure these are exited correctly and not 'red buttoned' to the background never to be seen again. I thought of putting the search criteria in the runtime store but concerned about timing and how best to remove the content if the application isn't launch correctly for what ever reason.

 

I'm sure if I pick I can find a solution but was wondering if anyone has any experiences they can share with me, may be a real obvious way of doing this without over complicating matters.

 

Thanks

Please use plain text.
Regular Contributor
Plato
Posts: 71
Registered: ‎07-11-2010
My Device: Bold 9000
My Carrier: none

Re: Launching application from context menu

I'd use similar approach

 

main app
* on startup - addGlobalListener
* on exit - removeGlobalListener
* on global event - if event == do_quick_search - display appropriate UI

context menu - when selected
* check if main app is running (get module / get process)
* if not - start it & wait a couple of seconds
* push a global event do_quick_search


-----
A good decision is based on knowledge and not on numbers.
Please use plain text.
Developer
BeMor
Posts: 171
Registered: ‎08-20-2008
My Device: Not Specified

Re: Launching application from context menu

Thanks for the reply Plato, Should I be concerned regarding the startup time of the application before posting a global event? Also I want the only screen in the stack to be the results relating to the quick search so I was thinking of exiting the application every time using a global event and starting a fresh. Is this a good idea doing it this way or would there be any downsides you can think of?

 

Thanks once again

Please use plain text.
Regular Contributor
Plato
Posts: 71
Registered: ‎07-11-2010
My Device: Bold 9000
My Carrier: none

Re: Launching application from context menu

To display only results from the quick search, I'd rather use separate application, something like this:

 

public static void main(String args[])
{
  if (args != null && args.length > 1 && args[0].equals("quick_search"))
  {
    QuickSearchApp app = new QuickSearchApp(args[1]);
    app.enterEventDispatcher();
  }
  else
  {
    MainApp app = new MainApp();
    app.enterEventDispatcher();
  }
}

 

 I don't think that you  should be concerned about having multiple instances of QuickSearchApp, but if you consider this an issue, you can close each app when it goes to background.

 

> Should I be concerned regarding the startup time of the application before posting a global event?

 

If you pass the global event to specific process id (the one that you got from run application), it will be handled by the core application inside it's event loop - whenever it is ready. So I think that you should not be concerned about startup time.

 


-----
A good decision is based on knowledge and not on numbers.
Please use plain text.