07-07-2012 02:06 PM
I would like to get some help & feedback from you
since I'm still new in the development process
I would like to make an Alarm clock app
that is somehow different to the one provided on the devices
Is that possible ?
And how do i get the device time ?
so that i compare it with my app alarm time
I read that i need to use RealtimeClockListener
and use the clockUpdated() method
but I still need guidance
Your help is highly appreciated
07-07-2012 04:40 PM
You can get the current time by using
long timems = System.currentTimeMillis();
use DateFormat to format it how you'd like. You can turn it into day, time, whatever.
SimpleDateFormat dateformat = new SimpleDateFormat("hh:mm aa"); //check java docs for other formatting methods here
DateField time = new DateField("", timems, dateformat );
you can convert to a string if thats how you want to display
You can do it in the clockUpdated method, I think it is invoked every minute the clock changes.
07-07-2012 07:10 PM
I'm guessing, because I have seen questions like this before, that this is some kind of assignment you have been given. Search the forum, other people have asked similar questions about creating alarm clock apps.
05-17-2013 11:48 AM
thanks for your reply!
Alright....I'm tring to start 5 threads to monitor current system time, interval 1 second, for a while the blackberry resource monitor report me that my app consume many power, so I think this is not a correct way to implement an alarm clock app, do you have any suggest for me?
05-17-2013 11:59 AM
Why do you need 5 Threads?
If all you are doing is creating an alarm clock to go off at specified times, then I assume you will be setting these times in minutes. In that case, the RealTimeClockListener is the approach you should use, because it gets a prompt every minute,
05-17-2013 12:16 PM
I doubt you need 3 Threads.
Remember that that BBOS is a single processor device so Threads do not run concurrently - by run here I mean use the processor.
In this case I would work on a single Thread which has a loop checking when next it needs to wake up. Once it figures that out, it will just do a wait for the time left (not a sleep). You can wake this Thread up if the user changes something, so that it can re-evaluate when it next needs to do something.
To do this you will need to understand wait()/notify() to make this work properly - so research that. This is a Java concept, not specific to BlackBerry, so you will find normal Java tutorials that talk about wait() and notify() on a shared Object.
05-17-2013 12:29 PM