[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2013-08-27 Thread Lai Vung
Thanks Jon.

It works very well for me. You saved me a day. Thank you.

Hai

On Sunday, December 7, 2008 2:56:10 PM UTC+7, Jon Colverson wrote:

 On Dec 5, 7:56 am, Jon Colverson jjc1...@gmail.com wrote: 
  On Dec 5, 6:41 am, Jon Colverson jjc1...@gmail.com wrote: 
  
   I'd been having some weird issues with AlarmManager seemingly not 
   firing my alarms when the device is asleep. I'm using the alarm to 
   start a service and I was acquiring my wake lock in onStart(). I tried 
   acquiring the lock in onCreate() instead, and that seems to have 
   solved the problem. 
  
  Oops. I spoke too soon. After some more testing that doesn't seem to 
  have helped. 

 I had another look at the AlarmManager documentation and I noticed 
 that it only talks about using alarms to broadcast events, not start 
 services. I changed things around to use a BroadcastReceiver instead 
 that acquires the lock in its onReceive() and stored the lock 
 reference as a static member of another class, following the example 
 of the AlarmClock application: 

 http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob_plain;f=src/com/android/alarmclock/AlarmAlertWakeLock.java;hb=HEAD
  

 That seems to have worked. I guess what was happening was that my 
 service starting alarms were being fired, but the device was sometimes 
 going back to sleep before I could acquire the wake lock. Apparently 
 the only guarantee that is made when an alarm is received is that the 
 onReceive will run to completion. 

 I just thought I'd post this in case anyone is ever searching for the 
 same problem. 

 -- 
 Jon 


-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2008-12-06 Thread Jon Colverson

On Dec 5, 7:56 am, Jon Colverson [EMAIL PROTECTED] wrote:
 On Dec 5, 6:41 am, Jon Colverson [EMAIL PROTECTED] wrote:

  I'd been having some weird issues with AlarmManager seemingly not
  firing my alarms when the device is asleep. I'm using the alarm to
  start a service and I was acquiring my wake lock in onStart(). I tried
  acquiring the lock in onCreate() instead, and that seems to have
  solved the problem.

 Oops. I spoke too soon. After some more testing that doesn't seem to
 have helped.

I had another look at the AlarmManager documentation and I noticed
that it only talks about using alarms to broadcast events, not start
services. I changed things around to use a BroadcastReceiver instead
that acquires the lock in its onReceive() and stored the lock
reference as a static member of another class, following the example
of the AlarmClock application:
http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob_plain;f=src/com/android/alarmclock/AlarmAlertWakeLock.java;hb=HEAD

That seems to have worked. I guess what was happening was that my
service starting alarms were being fired, but the device was sometimes
going back to sleep before I could acquire the wake lock. Apparently
the only guarantee that is made when an alarm is received is that the
onReceive will run to completion.

I just thought I'd post this in case anyone is ever searching for the
same problem.

--
Jon

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2008-12-05 Thread Noam Wolf

I was setting my AlarmManager in the wrong place, namely an onXxx
event.  What i did was set the AlarmManager on a user action (like
save or whatever) and that solved my problem.

Check it out Applications  Tools  ClockApps



On Dec 5, 2:56 am, Jon Colverson [EMAIL PROTECTED] wrote:
 On Dec 5, 6:41 am, Jon Colverson [EMAIL PROTECTED] wrote:

  I'd been having some weird issues with AlarmManager seemingly not
  firing my alarms when the device is asleep. I'm using the alarm to
  start a service and I was acquiring my wake lock in onStart(). I tried
  acquiring the lock in onCreate() instead, and that seems to have
  solved the problem.

 Oops. I spoke too soon. After some more testing that doesn't seem to
 have helped.

 --
 Jon
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2008-12-04 Thread Jon Colverson

On Nov 29, 12:15 pm, Noam  Wolf [EMAIL PROTECTED] wrote:
 I have a BroadcastReceiver which acquires a lock onReceive.  I use an
 alarm manager with AlarmManager.RTC_WAKEUP set to broadcast my
 intent.  I have found that when the phone is locked (and asleep) it
 will not wake up sometimes, and when it does many times it will have a
 delay (up to 30 seconds from when the alarm manager was supposed to go
 off).

I'd been having some weird issues with AlarmManager seemingly not
firing my alarms when the device is asleep. I'm using the alarm to
start a service and I was acquiring my wake lock in onStart(). I tried
acquiring the lock in onCreate() instead, and that seems to have
solved the problem. I know that doesn't help you with your
BroadcastReceiver, but perhaps you can rework your app to use a
Service instead?

--
Jon

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2008-12-04 Thread Jon Colverson

On Dec 5, 6:41 am, Jon Colverson [EMAIL PROTECTED] wrote:
 I'd been having some weird issues with AlarmManager seemingly not
 firing my alarms when the device is asleep. I'm using the alarm to
 start a service and I was acquiring my wake lock in onStart(). I tried
 acquiring the lock in onCreate() instead, and that seems to have
 solved the problem.

Oops. I spoke too soon. After some more testing that doesn't seem to
have helped.

--
Jon

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Strange behavior with AlarmManager.RTC_WAKEUP and PowerManager.WakeLock

2008-12-02 Thread Noam Wolf

ping... anyone?

On Nov 29, 12:15 pm, Noam  Wolf [EMAIL PROTECTED] wrote:
 I have a BroadcastReceiver which acquires a lock onReceive.  I use an
 alarm manager with AlarmManager.RTC_WAKEUP set to broadcast my
 intent.  I have found that when the phone is locked (and asleep) it
 will not wake up sometimes, and when it does many times it will have a
 delay (up to 30 seconds from when the alarm manager was supposed to go
 off).

 I don't understand how/what I'm doing different than the AlarmClock
 application since I'm acquiring the lock in the receiver.  I've also
 seen the screen turn on but then immediately turn off

 Does anyone have any ideas as to why this is happening?  Or has anyone
 run into this?  Is RTC_WAKEUP stable and trustworthy?

 Any help would be greatly appreciated.
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---