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
New Contributor
panfrano
Posts: 5
Registered: ‎03-01-2010
My Device: 9000Bold
Accepted Solution

Auto-run on startup not working

I try to launch my application on startup by selecting "Auto-run on startup" in BlackBerry Application Descriptor. I use also SystemListenerto detect system availability on startup. It works fine(application is launched) when I restart the phone by taking out battery.But  when I turn on/off the device by pressing button(some kind of sleep mode I guess), application is not launched on startup.

Is there any way to launch the application ofter tunring off/on the device by button?

Thanks in advance

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Auto-run on startup not working

SystemListener.powerOn is invoked during a soft power up.  You can add a SystemListener during auto-run processing, and then your System Listener methods will get invoked during soft power down and power up.  Give it a try to figure out what actually goes on and decide what you want to do, before you start implementing this.  Note also that RuntimeStore survives a soft power off - can be a useful place to put bits of data. 

 

Yes I agree, this is more a standby (sleep) mode than power off. 

New Contributor
panfrano
Posts: 5
Registered: ‎03-01-2010
My Device: 9000Bold

Re: Auto-run on startup not working

Thanks for answer Peter

SystemListener.powerUp() is invoked when i do not close application before going to stanby mode. When I close it , application is not started with "Auto-run on startup" setting when going back from standby mode. only when device is restarted by taking out battery. Is it how it should work?

Is there any way how to start application on going back from standby mode, or do I have to have aplication with SystemListener always running in background that will launch my application after powerOn detected?

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Auto-run on startup not working

What you see is correct. 

 

If you wish to detect soft power up, your Application must remain active in the background, so that the powerUp is detected. However if your application does currently exit (System.exit(..) on close, the SystemListener is lost.

 

But if your application is exiting when the user closes it, how does the user then restart it?  ,Effectively the soft restart has returned your application into the same state it was in when the user powered down?

 

This statement is slightly incorrect:

"do I have to have application with SystemListener always running in background that will launch my application after powerOn detected"

SystemListener is a function of the Application.  If the Application is closed, the SystemListener associated wit that Application is not going to be called.  So the comment "will launch" is not correct, your application is already running. 

New Contributor
panfrano
Posts: 5
Registered: ‎03-01-2010
My Device: 9000Bold

Re: Auto-run on startup not working

Trusted Contributor
Davidf65
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified

Re: Auto-run on startup not working

Hi Peter,

 On doing this, when I check the device logs, I get the following:

 

RuntimeException
	application already running in this process
	net_rim_cldc-10(4E68CC9F)
	 ApplicationProcess
	 appStarted
	 0x43A6
	net_rim_cldc-9(4E68CC9F)
	 Application
	 <init>
	 0x3272
	net_rim_cldc-15(4E68CC9F)
	 UiApplication
	 <init>
	 0x656E
	MyAppTest(5072CC65)
	 TheMainClass
	 <init>
	 0xED0
	MyAppTest(5072CC65)
	 TheMainClass
	 powerUp
	 0xE9C
	net_rim_cldc-27(4E68CC9F)
	 Events
	 dispatchSystemEvent
	 0x29DC
	net_rim_cldc-9(4E68CC9F)
	 Application
	 <private>
	 0x26CF
	net_rim_cldc-9(4E68CC9F)
	 Application
	 processNextMessage
	 0x1C3A
	net_rim_cldc-9(4E68CC9F)
	 Application
	 enterEventDispatcher
	 0x1B61
	MyAppTest(5072CC65)
	 TheMainClass
	 main
	 0xF64
What should I do to prevent this from happening?

Thanks

David