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: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone
Accepted Solution

send the application to foreground on system startup for 5 seconds..

[ Edited ]

Hello everyone, I have an application which is autorun on startup. I need that the application stays on foreground for 5 seconds as soon as the system starts. How can I do this? Please help. 

Thanks..

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

Re: send the application to foreground on system startup for 5 seconds..

Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: send the application to foreground on system startup for 5 seconds..

Thanks for your reply Peter. But, it won't work in my case. I need my UiApplication to start on device startup and stay in foreground for 5 seconds atleast. I need the user to do some keypresses in those 5 seconds which I manipulate through KeyListener. I am not able to do this. I have tried Thread.sleep(5000) but it also doesn't work. 

 

 

 

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

Re: send the application to foreground on system startup for 5 seconds..

[ Edited ]

Can you provide a little more detail on precisely which parts of this are causing your problems.  For example, is it the starting, the retaining a screen for 5 seconds, or why you need to capture the key strokes, or if you expect the user to have some visible indication that your application is in the foreground.   

 

The start on start-up should be easy, but you need to take note of this:

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

 

Then the best think to do, is probably NOT to push your UiApplication t the front.  Instead keep it in the background and push a GlobalScreen.  Use the GlobalScreen to capture the keystrokes you want.

 

Regarding keeping this active for more than 5 seconds, with your GlobalScreen, I don't see the problem in being able to do this. 

 

But I also don't really understand why you would want t do this, so can't really understand your use case and requirements, which doesn't help trying to figure this out.  Perhaps you can explain what you are trying to achieve, as well as explaining which parts are giving you grief. 

Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: send the application to foreground on system startup for 5 seconds..

Thanks, the link was really helpful. I didn't know this before. 

I need to take some input from the user before the application can perform its functions. For this I need an interval of 5 seconds. My problem is that I can't have my applicaion stay in foreground for 5 seconds.

 

I will try it with the GlobalScreen now. Thanks you for your reply. Smiley Happy

Trusted Contributor
Posts: 141
Registered: ‎02-15-2012
My Device: 9800
My Carrier: Airtel

Re: send the application to foreground on system startup for 5 seconds..

Hi Nikita,

 

You can also use some splash screen or some some Activity indicator at the starting of App.

 

If you will lock the App for 5 seconds at the start, it will not good for App. So add any Splash screen or Activity loader at the starting of App.


Please press like if you satisfies with the solution.

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

Re: send the application to foreground on system startup for 5 seconds..

@nikita18

 

Sorry I'm still not clear on what you are trying to do or what you are having difficulty with.  To make further comment I think we need to know more about your requirement.  For example, you say

a) "I need to take some input from the user before the application can perform its functions"

Does this need to be at startup?  Or startup of your application?  What happens if you do not get this input?

b) "For this I need an interval of 5 seconds"

Why 5 and not 6 or 4.  What should the user see while this is going on?

 

Also, how does the user know that they have to input this information and why would they want to do it? 

 

@ankitagrawal. I am not clear on what you are trying to say here or why a splash/loading screen would be helpful.  Also how you can make sure a splash/loading screen stays visible, and what do you mean by locking the application.  Perhaps you could review the question and your answer and explain it better?  Thanks

Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: send the application to foreground on system startup for 5 seconds..

Sorry for late reply. And thanks for your time peter. I have kind of accompplished what I was trying to do with Thread.sleep() and editing my code. But I'm still not happy about the code. 

Actually, I need 3 key presses as a password from the user to begin my app to further start functioning. If the password is incorrect, it should close my app. And I need to do that when the device starts up. 

I think 5 seconds is enough for the user, that is why I said 5 seconds. No other special reason. I think I have made myself clear now. Smiley Happy

Thanks.

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: send the application to foreground on system startup for 5 seconds..

If this is solved can you mark it appropriately.  Instructions in Help link at top.

 

If not, then given your requirements, I would go with a Global Dialog screen and a DialogCloseListener, that will kill your app if the response is not correct.  .