View Single Post
Old 03-05-2009, 09:21 AM   #2 (permalink)
Knows Where the Search Button Is
Join Date: Jun 2008
Model: 9000
Carrier: Vodafone
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts


1. Create your main UI CLDC application, say MySampleApp. Select Properties -> Application then select the
Options Auto-run on startup (This will make your application auto-run on hard reset) and System module (No entry point from Icon).

2. Add a GUI option for enable/ disable the autorun option in your main project( MySampleApp).

3. Create a persistant store for storing the status of auto-run option.

4. Create an alternate entry point for your application.( Create a new project , say MySampleAppAlt . Go to Properties-> Application then select project type xxx8220;Alternate CLDC application entry pointxxx8221; and Select xxx8220;MySampleAppxxx8221; as Alternate entry point for: . Add an argument say xxx8220;fromGUIixxx8221; to arguments passed to option.)

5. Add your application Icon file in MySampleAppAlt project and set as application Icon.

6. Create a dummy or monitor Say xxx8220;SampleAppMonitorxxx8221; CLDC application with SystemModule option selected ( This will remove the default Icon ) which extends Application and implements GlobalEvent Listener and SystemListener interfaces.

7. Override the PowerUp() method of SystemListener with this code

   int modHandle =  CodeModuleManager.getModuleHandle("MySampleApp ");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);

8. Override the eventOccurred () method of SystemListener with this code

if (guid == 0x12345678) 
9. Change your exitApplication() ( your exit point of main application ie; MySampleApp) or onClose() to start SampleAppMonitor upon exiting from your application.

If(AutoRun) // store the status of user selection in AutoRun variable
int modHandle = CodeModuleManager.getModuleHandle("SampleAppMonitor ");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
10. In public static void main(String[] args) of MySampleApp, get the status of Auto-run from persistant store and say it is boolean AutoRun. Add

if (args != null && args.length > 0 && args[0].equals("FromGUI"))
            dosStartUpProcess();// continue with your application. Entry from alternate entry point.              
else if( false == AutoRun) // hard Reset and  autorun option disabled by user.
11. Post a global event from your main application ( MySampleApp) to close the SampleAppMonitor. You can post this event from main just after enter your main application

/for closing  SampleAppMonitor application
                ApplicationManager appMgr = ApplicationManager.getApplicationManager();
                int moduleHandle = CodeModuleManager.getModuleHandle("SampleAppMonitor ");      
                ApplicationDescriptor[] appDes = CodeModuleManager.getApplicationDescriptors(moduleHandle);           
                int processId = appMgr.getProcessId(appDes[0]);
                appMgr.postGlobalEvent(processId, 0x12345678, 0, 0,null,null);

Last edited by jobincantony : 03-05-2009 at 09:57 AM.
Offline   Reply With Quote