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: 588
Registered: ‎05-29-2009
My Device: 9100

Execute application after installation

Hey there!

 

I'm trying to make run my application when i install it in the device, but not when i restart the device. The code i'm trying with is this...

 

    public static void main(String[] args)

    {

       if ( args != null && args.length > 0 && args[0].equals("alternate") ){

          //  Alternate entry point
          Bitmap icon = Bitmap.getBitmapResource("icon.png");
          HomeScreen.setRolloverIcon(icon);
                             
       }
         
          MainApplication theApp = new MainApplication();
          theApp.requestForeground();
          theApp.enterEventDispatcher();
     
    }



    public MainApplication(){
             pushScreen(new MyScreen());           
    }
    

 

Any idea? Thanks in advance.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Execute application after installation

As far as I know when application is set "Run on startup" it executes just after it is installed.

 

But this application will run after every device restart.

 

There is no other way to force an application to be started just after installation.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Execute application after installation

Here is a suggestion: 

 

1. set the application for auto-start

2. after the first startup, store a property in persistence that says "I started already"

3. On subsequent restarts, ignore the "system" entry to main() if this property is set.

 

 

Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: Execute application after installation

[ Edited ]
Thanks for your answer. Good idea, but... how do i store that property in persistence? I don't know exactly how to implement that in my code...
Message Edited by ibarrera on 07-16-2009 02:16 AM
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Execute application after installation

Check this pdf file:

 

http://na.blackberry.com/eng/deliverables/3299/JDE_4.5_Fundamentals_Guide.pdf

 

There is a chapter: Memory and data storage.

 

Check for it.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Execute application after installation

Also check this article:

 

Storing data persistently