BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-05-2009, 09:18 AM   #1
jobincantony
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 9000
PIN: N/A
Carrier: Vodafone
Posts: 17
Post Hi, Blackberry JDE provides an option for making your application Auto-run on start

Please Login to Remove!

Hi,

Blackberry JDE provides an option for making your application Auto-run on startup. But surprisingly these applications will auto-run only after hard reset (Alt + cap + Del or battery pull-up).

But for a user perspective the application will restart on Soft reset too (turn off and turn on by pressing power button).

I have faced lot of issues for making a CLDC application auto-run in all the above cases and make the auto-run option is user defined.

Now I have successfully implemented this and tested with OS versions 4.0.2 to 4.6.

I have made a monitor application with my Main application to do the Soft reset activity.

The monitor application is a CLDC application which extends the Application class and implements the SystemListener (for monitoring the powerUp() after reset) and GlobalEvent Listener (for closing the monitor application).

Upon exiting from my main application I will check for Auto-run option enabled and if yes I will start the monitor application before exiting from mainApp. The monitor application will monitor the powerUp() status after reset and will start the MainApplication.

Main application will close the monitor application by posting a globalevent to monitor application.

The monitor application is a system module. So there is no ICON for it and we can add the .cod file of the application as a dependent module with our main application. The size of the monitor application is also very less (2k).

This approach may help someone wants to make their CLDC application auto-run in all the scenarios.
Offline  
Old 03-05-2009, 09:21 AM   #2
jobincantony
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 9000
PIN: N/A
Carrier: Vodafone
Posts: 17
Post

Steps

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

Code:
   int modHandle =  CodeModuleManager.getModuleHandle("MySampleApp ");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
            ApplicationManager.getApplicationManager().runApplication(apDes[0]);

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

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


Code:
If(AutoRun) // store the status of user selection in AutoRun variable
{
int modHandle = CodeModuleManager.getModuleHandle("SampleAppMonitor ");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
ApplicationManager.getApplicationManager().runApplication(apDes[0]);
}
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

Code:
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.
{
 System.exit(1);
}
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

/
Code:
/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  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF picture

6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF

$155.59



CBB Capacitors 100V 250V 400V 630V 1600V Polyester Film Capacitor-Various Values picture

CBB Capacitors 100V 250V 400V 630V 1600V Polyester Film Capacitor-Various Values

$233.05



CBB61 250V  Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF picture

CBB61 250V Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF

$123.45



6.3V~450V 10uF~10000uF High Frequency LOW ESR Radial Electrolytic Capacitor picture

6.3V~450V 10uF~10000uF High Frequency LOW ESR Radial Electrolytic Capacitor

$42.99



35+5 35/5  uF MFD 370-440 V AC (10x) High Quality  Dual Run Capacitor CBB65-R picture

35+5 35/5 uF MFD 370-440 V AC (10x) High Quality Dual Run Capacitor CBB65-R

$69.00



1/5/10pcs 100V~400V 0.1uF~20uF MKP Audio Metallized Polypropylene Film Capacitor picture

1/5/10pcs 100V~400V 0.1uF~20uF MKP Audio Metallized Polypropylene Film Capacitor

$39.42







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.