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
Regular Contributor
Posts: 54
Registered: ‎03-11-2010
My Device: bold 2
My Carrier: Software engineer

auto-start application on the emulator

Hello,

I'm trying to build my application in order to start as soon the emulator start. I've tried modifying the .jad file on the line:

 

RIM-Midlet-Flags-1: 0

 

switching the flag to 1...but it doesn't work.Any help?

 

thanks a lot !

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: auto-start application on the emulator

Have you tried using the JDE or Eclipse to sewt your application to autostart? Right-click the project and click "Properties" from the menu. There is a check box labeled "Run application on startup" that will run your application as soon as any device or simulator powers on.

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Regular Contributor
Posts: 54
Registered: ‎03-11-2010
My Device: bold 2
My Carrier: Software engineer

Re: auto-start application on the emulator

I've already tried it,even setting startup tiers different from 7...but nothing.

Regular Contributor
Posts: 54
Registered: ‎03-11-2010
My Device: bold 2
My Carrier: Software engineer

Re: auto-start application on the emulator

 I was able to create an autostart application:

this is the code of  a testing app:

 

 

import javax.microedition.media.Manager;

import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.SystemListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

public class MyApp extends UiApplication implements SystemListener {
    
    private static MyApp theApp;    
    private SalutationScreen mainScreen = null;
    
    public static void main(String[] args){
        System.out.println("*** main(String[] args ***");
        if(theApp==null){
            theApp = new MyApp();           
        } else{ 
	   // don't think it ever gets here, but no harm for now
            theApp.requestForeground();
            System.out.println("theApp is not null!!!");
        }        
        theApp.enterEventDispatcher();
    }
    
    public void powerUp() {
        System.out.println("*** powerUp() ***");
        startUpProcessing();        
    }

    public void powerOff() {
        System.out.println("*** powerOff() ***");
       
	/* setting mainScreen = null was giving me the multiple instances problem.  sounds weird, but it was giving me the test#1 I spoke about.  when I remove this line, it no longer gives me the test#1 problems I had */
	//mainScreen = null;    
     
        try{
            theApp.requestBackground();
        } catch(Exception e){
            e.printStackTrace();
        }
    }
    
    private MyApp(){
        System.out.println("*** MyApp() ***");
        this.addSystemListener(this);

        if( ApplicationManager.getApplicationManager().inStartup() ) {
            // handled in powerUp()
        } else{            
            startUpProcessing(); 
        }

    }

    private synchronized void startUpProcessing() {
    	System.out.println("!!!startUpProcessing()*****");
        try{
            if(mainScreen == null){            
                this.invokeLater( new Runnable() {
                    public void run() { 
                        doStartupWork(); 
                    }
                } );
            } else{
                this.requestForeground();
                System.out.println("mainScreen ========>");
            }
        } catch(Exception e){
            System.out.println("startUpProcessing() Exception--> " +e.toString());
        }
        
    }

    private void doStartupWork(){
        this.requestBackground();

        mainScreen = new SalutationScreen();        

        // ... add cool stuff here ...blah blah blah...

        pushScreen(mainScreen);    
        UiApplication.getUiApplication().requestForeground();     
                
    }

	public void batteryGood() {
		// TODO Auto-generated method stub
		
	}

	public void batteryLow() {
		// TODO Auto-generated method stub
		
	}

	public void batteryStatusChange(int status) {
		// TODO Auto-generated method stub
		
	}


} 

 SalutationScreen is just a simple screen with a textField,nothing really important to be reported.

 

I also set two flags in the project properties,under the Application panel:

- system module

- auto-run on startup.

 

Now,the application is working correctly and starting up as soon as the emulator is started. My question now is: Is there a way to set these two flags outside of Eclipse (like modifying some file?)


thanks a lot

 

 

Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: auto-start application on the emulator

I don' think you can set these two values from outside..

 

System module - this option is used to run the application in the background.

Auto-Startup       - this option enables the application to automatic startup with each reboot of device.

 

Can you elaborate what you want to do now..?

 

Best Regards,

Kanak Sony

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Regular Contributor
Posts: 54
Registered: ‎03-11-2010
My Device: bold 2
My Carrier: Software engineer

Re: auto-start application on the emulator

they point is that I need to deploy the application without eclipse.Currently I can:

- building it using ant

- make it running from console copying the right files in the simulator directory

 

I need the application to be started as soon the emulator start,but for doing it currently I need Eclipse for setting these two project properties. According to what I've seen till now these infos are recorded in a .JDP file like this:

 

 

## RIM Java Development Environment
# RIM Project file
#
#
AddOn=0
AlwaysBuild=0
[AlxImports
]
AutoRestart=0
[ClassProtection
]
[CustomBuildFiles
]
[CustomBuildRules
]
[DefFiles
]
[DependsOn
]
ExcludeFromBuildAll=0
[Files
src\MyApp.java
src\SalutationScreen.java
]
HaveAlxImports=0
HaveDefs=0
HaveImports=0
[Icons
]
[ImplicitRules
]
[Imports
]
Listing=0
Options=-quiet
OutputFileName=test
[PackageProtection
]
RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0  //this is the startup zone
StartupTier=7
SystemModule=0
Type=0
UserData=|src

 

changing 

 

RunOnStartup=0

to

RunOnStartup=1

 doesn't change anything if I do it manually. But there should be a way to do it since Eclipse can do it!!! Smiley Happy

 

Regards