09-03-2008 03:27 AM
i have an application with two possible main objects:
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:
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
Solved! Go to Solution.
09-03-2008 09:31 AM
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
09-05-2008 03:18 AM
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
09-05-2008 12:40 PM
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.
09-08-2008 04:34 AM - edited 09-08-2008 04:35 AM
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