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
Guigui77360
Posts: 34
Registered: ‎07-24-2009
Accepted Solution

Close my application after 5 seconds

[ Edited ]

Hello,

 

When I launch my app, there is a first screen who ask the user to press on a button to start the real application. But I want that after 5 seconds, if any button is pressed, the application close.

I really don't know how to manage that ! Could you help me with some sample code please ?

 

Here is the code I'm using :  

 

 

import net.rim.device.api.system.*;

import net.rim.device.api.util.*;

import net.rim.device.api.ui.*;

import net.rim.device.api.ui.component.*;

import net.rim.device.api.ui.container.*;

 

final class Test extends UiApplication {

public static void main(String[] args)

{

Test app = new Test();

app.enterEventDispatcher();

}

 

Test()

{

pushScreen(new EditScreen());

}

 

private class EditScreen extends MainScreen {

public EditScreen()

{

add(new EditField("Press the right or left convenience button.",""));

}

 

protected boolean keyDown(int keycode, int time)

{

if(keycode == 1245184 || keycode == 1376256)

{

System.out.println("Here I launch my application");

}

return super.keyDown(keycode, time);

}

}

}

 

Thank you for your help !! 

 

 

Message Edited by Guigui77360 on 08-07-2009 11:51 AM
Please use plain text.
Developer
bikas
Posts: 984
Registered: ‎02-10-2009

Re: Close my application after 5 seconds

You can achieve this using Timer class (java.util.Timer) and TimerTask class (java.util.TimerTask).

See javadoc for details.

 

Regards

Bikas

Please use plain text.
Developer
Guigui77360
Posts: 34
Registered: ‎07-24-2009

Re: Close my application after 5 seconds

Thank you !! That is exactly what I was looking for :smileyhappy: !!
Please use plain text.