Hi guys thx for your help, been playing around with it and I tried setting up a service which works, but this will run in the background all the time so if I use an alarm manager how accurate is it can you set one for say 30 seconds time, or is it still bad to use a service even though all its doing is waiting for handler.post() to come along to play a sound. The timer is designed to have several times per timer so each timer will finish several times, i.e pyramid splits, and can have many timers
On 21 November 2010 23:30, Dianne Hackborn <hack...@android.com> wrote: > You don't need to try around with different things, the behavior is very > well defined: if you are not holding a wake lock, the CPU is allowed to go > to full sleep, so no code can be executed until an external event wakes it > up. A thread sitting there waiting on a timer is never an external event. > > If you need to make sure you wake up even if the CPU is asleep, use the > AlarmManager. > > On Sun, Nov 21, 2010 at 8:21 AM, Paul Townsend <deer...@gmail.com> wrote: > >> Just tried that bvut dose the same thing, although I have used >> countdownTimer in a custom TextView that I wrote so I could have a countdown >> timer for the UI and this dose not pause. I might look into to transfering >> the other timer bits to the text view and use that as a all in one timer >> solution and see if that works. >> >> >> On 21 November 2010 03:34, Hal <dsheppar...@gmail.com> wrote: >> >>> You may want to look at CountDownTime also. It seems to work fine >>> (even when the Screen goes off). >>> I took the following from the web: >>> >>> public class MyCount extends CountDownTimer { >>> public MyCount(long millisInFuture, long countDownInterval) { >>> super(millisInFuture, countDownInterval); >>> } >>> >>> public void onFinish() { >>> counter = new MyCount(5000, 1000); >>> counter.start (); >>> } >>> >>> public void onTick(long millisUntilFinished) { >>> tv.setText("Hal:" + timer.getTime()); >>> } >>> } >>> >>> >>> The timer component uses a "Live" Jt component (separate thread): >>> >>> private void timer() { >>> >>> JtFactory main = new JtFactory (); >>> >>> >>> // Create the component >>> >>> timer = (Timer) main.createObject (Timer.JtCLASS_NAME); >>> >>> // Asynchronous processing of messages. >>> main.setSynchronous(false); >>> main.sendMessage (timer, new JtMessage (Timer.UPDATE_TIME)); >>> >>> >>> } >>> >>> >>> ..... >>> counter = new MyCount(5000, 1000); >>> counter.start(); >>> setContentView(tv); >>> ....... >>> >>> On Nov 20, 3:58 pm, Paul Townsend <deer...@gmail.com> wrote: >>> > I made a simple countdown timer and it works as expected when plugged >>> > in via usb for debugging but when I take it off debugging and the >>> > screen goes off either time out or power button the handler fails to >>> > fire at the end time. I have created a custom timer class that gets >>> > created from the main activity when needed, because its able to have >>> > multiple countdowns running at the same time. Am I right in thinking >>> > that the handler just gets paused when the screen goes off and if so >>> > what are my alternatives. The activity is still in the foreground and >>> > I assumed the handler would still fire if the screen goes off. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to android-developers@googlegroups.com >>> To unsubscribe from this group, send email to >>> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en