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
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Device clock listener

 

I want to add listener on device clock . 

 

To make specific action ( load data from web services and open screen ) at specific time like every day @7:00pm 

 

how can I make this ?

 

Developer
aykarthik
Posts: 187
Registered: ‎08-13-2008
My Device: Not Specified

Re: Device clock listener

You can use TimerTask

Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: Device clock listener

i know this .

the question is where to do it . and to put the application in the BackGround ??

Developer
aykarthik
Posts: 187
Registered: ‎08-13-2008
My Device: Not Specified

Re: Device clock listener

Try this.

 

Calendar cal;
Timer timer;

Date dd = new Date();
cal = Calendar.getInstance();
timer = new Timer();

timer.schedule(new SpecificAction(), cal.get(Calendar.HOUR_OF_DAY));

 

class SpecificAction extends TimerTask
{
public void run()
{
try
{

//write your code with condition. minutes & secs needs to be 0.
}
catch(Exception e)
{

}
}
}

Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: Device clock listener

but where i should put this code . 

and how to put my application to work in BackGround ?? 

 

Thanks

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

Re: Device clock listener

If you search around, for example, here and the docs, you should be able to get answers to questions like this:

 

I typed "background" in the Search box and found this:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-Background-Application/ta-p/445226