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
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Two process one app problem

Hi all,

 

I want to have two isolated processes inside one app without using threads. Is it possible?

What I am trying now is that i am having 2 separate apps and one app invoke the other, but problem with this approach is that application icon of other app is visible. which I dont want. Any idea on this?

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Two process one app problem

you can use alternate entry points to start new applications.

----------------------------------------------------------
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: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: Two process one app problem

you mean that I can use the same app to instatiate same app while previous one is still in used with different arguments and then decide based on arguments what is need to be done.

 

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 74
Registered: ‎01-03-2010
My Device: Not Specified

Re: Two process one app problem

[ Edited ]

by two process your one is background and other one is UI

 

use like this

 

 

static void main(String[] args)
  {
  String launch = null;
  if (args != null && args.length > 0)
  {
  launch = args[0];
  }

  if (launch != null)
  {
  if (launch.equals("background"))
  // if(!launch.equals("background"))
  {
  //start the background process
  //this is an auto starting system module entry point
  App app = App.getInstance();

  app.invokeLater(new Runnable()
  {
  public void run()
  {
  ApplicationManager appManager = ApplicationManager.getApplicationManager();
  //sleep until the device is started
  while (appManager.inStartup())
  {
  try
  {
  Thread.sleep(500);
  }
  catch (Throwable error)
  {
  // nothing
  }
  }
  App.getInstance().initialize();
  }
  });

  app.enterEventDispatcher();
  }
  else if (launch.equals("gui"))
  {
  //start the UI process
  //this is the main icon entry point
  UiApp uiApp = UiApp.getInstance();

  uiApp.initialize();
  // uiApp.runAudioPlayer();
  //instantiate the first screen
  FirstScreen firstScreen = new FirstScreen();
  uiApp.pushScreen(firstScreen);

  uiApp.enterEventDispatcher();
  }
  } 

make another project with only icon , make it alterante enty point for UiApplication, so by default you background process will run (as the original project is system module and auto startup here argument "background"   )

 

by two process your one is background and other one is UI

Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: Two process one app problem

Thanx for reply.

But the thing is I don't want my process to sit in background and keep running. It will be invoked by UI process when needed and it will be having some UI part as well and after doing its job it will exit.

 

So its like process1 will call process2 whenever needed process2 display will come in foreground. After process2 is done with it's job it will simply exit and user will be using process1.

 

Why i need 2 processes? Its just that if i can do this way then it will solve lots of stuff for me.

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 74
Registered: ‎01-03-2010
My Device: Not Specified

Re: Two process one app problem

your background process can be an UiApplication one also

 

by inter process communication you can invoke it's Ui part for the job and also can exit that Ui/Screen

 

just use global event or runtime store ( oops app will be still be running) . Can't give you right choice unless you clear your cause for 2 processes

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Two process one app problem

If you want the second application to exit after it's done, it sounds like you actually want to use a thread. They are not that scary.