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
Contributor
senthil_25
Posts: 45
Registered: ‎11-10-2010
My Device: Not Specified

how to move the mainscreen to background?

How to move the mainscreen to background

following is the code i used so far...

 

 

public class MyApp extends UiApplication

{

public static void main(String[] args)
{
 MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}

 

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

}

 

 

public final class MyScreen extends MainScreen
{

public MyScreen()

{

check_schedule();

}

 

 public void check_schedule()

{

UiApplication.getUiApplication().requestBackground();

}

}

 

 

but it is not working as i am looking for..

Please use plain text.
Developer
simon_hain
Posts: 15,873
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to move the mainscreen to background?

requestBackground moves the whole application into the background.
what is "not working"?
----------------------------------------------------------
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
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: how to move the mainscreen to background?

You are trying to requestBackground in the application constructor, before it has entered the event loop. I'm not sure whether it can work at this moment.

 

I would either move requestBackground to the MyScreen's onUiEngineAttached or wrap pushScreen in invokeLater which will postpone the creation of the screen to the moment when your application is fully functional.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Contributor
senthil_25
Posts: 45
Registered: ‎11-10-2010
My Device: Not Specified

Re: how to move the mainscreen to background?

Then tell me how to move the application to background.. programmatically 

Please use plain text.
Developer
simon_hain
Posts: 15,873
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to move the mainscreen to background?

arkadyz is probably right. use invokelater.

UiApplication.getUiApplication.invokeLater(); with a runnable in it that calls requestBackground.
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to move the mainscreen to background?

[ Edited ]

Simon's post answers that question.

 

Can you clarify if you are trying to start the application in the background, or have some control that allows the user or your logic to decide it should be in the background?

 

Remember also that the term background means different things depending on context.  Perhaps you could explain what you mean by background? 

 

Edit just noted Simon's second post, hopefully this is now redundant. 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: how to move the mainscreen to background?


simon_hain wrote:
arkadyz is probably right. use invokelater.

UiApplication.getUiApplication.invokeLater(); with a runnable in it that calls requestBackground.

In fact, you can even skip the (usually necessary) UiApplication.getUiApplication() - this inside your application constructor (where you are pushing your main screen) is your UI application, so simple invokeLater(new Runnable() { .... }) should be enough.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.