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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 33
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

alternate entry point without restart

i have an application with two possible main objects:

 

  • UiApplication, for foreground process, we call it FG_UIApp
  • Application for background process on auto-run-startup, we call it BG_App


For debugging I want to kill the BG_App by sending it a GlobalEvent from FG_UIApp. Ok, this works perfect. Now the BG_App doesn't run. It only runs again, when I do a full reboot. But now I would like to be able to start the BG_App again without reboot. I thought of a way like this:

 

  1. user clicks the application 
  2. now checking, if BG_App is running, when it doesn't run, just start it
  3. for the user nothing happens, so he will again click the app
  4. now checking, if BG_App is running -> it runs, so now we can start FG_UIApp

For this I implemented the following code. Step 1 + 2 are working, but when I do step 3 the debugger tells me, that my application is already running. Is there any way to simulate the autorun-entry-point without rebooting?

 

 

public static void main(String[] args) { boolean startbackground = false; if ( args.length > 0 && args[0].equals("autostart")) startbackground = true; else { boolean runtimestorevalues_are_existing = false; // checking some values in the runtime-store, // which are set by BG_App

// if these values, don't exist, we start // the background-process if (!runtimestorevalues_are_existing) startbackground = true; } if (startbackground){ new BG_App().enterEventDispatcher(); } else { new FG_UiApp().enterEventDispatcher(); } }

 

 Regards, Anil

 

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: alternate entry point without restart

Have a look at the link below.  You could get the ApplicationDescriptor for your alternate entry point and start it this way.

 

How To - Launch a third party application from another third party application
Article Number: DB-00455

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 33
Registered: ‎07-16-2008
My Device: Not Specified

Re: alternate entry point without restart

Hello Mark!

 

it still does not work. lets call my application "foo". I tried many different combinations with invoking foo by an application-descriptor following your provided example. It seems, that the provided example works for 3rd-party-applications to invoke ANOTHER  3rd-party-application. But it seems not to work for foo to invoke foo. In every combination I tried, every time when foo invokes foo, the debugger says:

Starting foo Started foo(111) JVM: bklt @9922: timer JVM: bklt @9922: idle 3 JVM: bklt @9923: setTimer 19 Starting foo foo already running

 Anil

 

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: alternate entry point without restart

The behaviour you are seeing is expected.  Alternate entry points do not equal 2 copies of an application running at the same time.  Alternate entry points allow an application to take different actions based on how it was started. 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Highlighted
Developer
Posts: 33
Registered: ‎07-16-2008
My Device: Not Specified

Re: alternate entry point without restart

[ Edited ]

Hello Mark!

After playing with modifying ApplicationDescriptor it works. The solution is here:

 

 

 

/*
my cod-module is called foo
in my jde I have 2 projects
- foo (the gui-application, called with no arguments)
- fooautostart (the backgroundapp, called with the argument "autostart",
it is generally called, when the device is booting)
*/
public static void main(String[] args) {
if ( args.length > 0 && args[0].equals("autostart")){
new BG_App().enterEventDispatcher();
}
else {
RuntimeStore rts = RuntimeStore.getRuntimeStore();
boolean runtimestorevalues_are_existing = false;
/*
now checking some values in the runtime-store,

which are set by BG_App; if these values, don't exist,

we have to invoke the background app in simulating the

startup-entrypoint;
*/
if (!runtimestorevalues_are_existing){
try {
int modHandle = CodeModuleManager.getModuleHandle("foo");
ApplicationDescriptor[] apDes =
CodeModuleManager.getApplicationDescriptors(modHandle);
String[] args_for_descriptor = {"autostart"};
ApplicationDescriptor descriptor =
new ApplicationDescriptor (apDes[0], "fooautostart", args_for_descriptor);
ApplicationManager.getApplicationManager().runApplication(descriptor);

}
catch (Exception e){
System.out.println("background start exception ex: " +
e.toString() + ": " + e.getMessage();
}
}
new FG_UiApp().enterEventDispatcher();
}
}

Thanks and best Regards to Canada.

Anil


 

Message Edited by anildeveloper on 09-08-2008 10:35 AM