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: 66
Registered: ‎08-28-2010
My Device: 9630

Application Running in Background

Hi,

 

 i am developing an application and i have two  basic requirements for my application. The requirement is as below :

 

1.  " when blackberry phone is restart, my application should auto run in background mode and after that if user click

on application icon or select icon in switchapplication then my application should come in foreground."

 

2 ." when user close my application i keep my application running in background and when again user press my application icon my application should come in foreground.

 

For 1, i am selecting the autostartup option in eclipse so it keep my application running. but i want my run in background and when user press application icon it should immediately come in foreground.

 

for2, i am adding single line code in onClose() method 

 

      UiApplication.getUiApplication().requestBackground();

 


can any one help me or provide the sample code so i can complete my basic 2 requirements.

 

Regards,

 

Developer
Posts: 16,639
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Application Running in Background

you are on the right track.
also add "return true" to the onClose method below the requestBackground to indicate that you have handled the event.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,623
Registered: ‎07-14-2008
My Device: Not Specified

Re: Application Running in Background

and for 1, just include a requestbackground() in the startup and the user should not see your application start up.

 

But be aware of this:

http://supportforums.blackberry.com/t5/Java-Development/Write-safe-initialization-code/ta-p/444795