Not sure this is it, but I noticed on this line of your code:

pendingIntent = PendingIntent.getBroadcast(ctx, 0, intent, 
PendingIntent.FLAG_UPDATE_CURRENT);

You are sending a 0 as the second argument, try sending something other than 
0 there. I've noticed in my own experience that this doesn't like to be 
zero. Also, try changing the flags to:

PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT

I've used this combination with my RingLock application and it has never 
failed me. I had issues when sending a 0 as the request code and the flags 
that don't cancel previous timer events.

Steven
Studio LFP
http://www.studio-lfp.com


On Sunday, October 23, 2011 3:24:36 PM UTC-5, John Goche wrote:
>
>
> Kostya,
>
> Thank you for your reply.
>
> However left me give an update on the testing I have carried out. I have 
> reinstalled the app
> from scratch and set alarms to expire every five minutes (each time an 
> alarm goes off it sets
> up the next one for the next five minutes). Here is what I have observed:
>
> - The first alarm goes off just fine and I see the popup window and hear 
> the sound.
>
> - If I keep fiddling with the device the next alarm goes off and I see the 
> popup window
>   and hear the sound so long as I keep fiddling with the device.
>
> - As soon as I have not fiddled with the device for five minutes (the 
> screen goes
>   blank after one minute) the alarm goes off and the popup window exists 
> behind
>   the darkness and I hear the sound, **** but at the next alarm time the 
> popup
>   window is not displayed, and neither the next one nor the next one and so 
> on ****
>
> - Then when I press a hardware button and the screen lights up the next 
> alarm that
>    goes off has the popup window pop up and the sound play.
>
> - Again, if I do not touch the phone, the five minute later alarm sounds 
> but not the
>   next one nor the next one.
>
> In adb logcat the only suspicious line I can suspect is the following after 
> I try to launch
> my activity:
>
> D/KeyguardViewMediator( 1563): 
> <!>com.android.internal.policy.impl.KeyguardViewMediator 643<!> 
> wakeWhenReadyLocked(4)
>
> In "dumpsys alarm" I see all of my 11 wakeups and 11 alarms.
>
> %%%%% So now I must learn how to keep the CPU running or when the alarm 
> goes off I will not
> be able to pop up the window and play the sound. When I leave the phone for 
> a while the CPU
> hybernates or something it seems, so my  RTC_WAKEUP calls the broadcast 
> receiver but does
> not pop up the intent it seems.
>
> Can someone please teach me how to use wakelocks and exactly what they are 
> so that I may
> fix this problem either by keeping the CPU running all the time, or in some 
> more efficient way
> if possible?
>
> Thanks a lot,
>
> John Goche
>
> On Sun, Oct 23, 2011 at 6:35 PM, Kostya Vasilyev <kman...@gmail.com>wrote:
>
>  Hi,
>>
>> No need to keep a PendingIntent reference - they are compared by Android 
>> like Strings (one could say), based on their content, not just by reference. 
>> In fact, setting an alarm automatically cancels all alarms that may have 
>> been set with the same pending intent.
>>
>
> The problem is that in my function sometimes based on what the user does in 
> the user interface I sometimes need to
> cancel the alarm without setting a new one, so that is why I keep the 
> static pending intent around, otherwise how do I
> go about cancelling the alarm without setting a new one?
>  
>
>>
>> As far as the sound goes.
>>
>> Wake-up alarms only hold the wake lock long enough to call onReceive.
>>
>
> What kind of wake lock? Because I see there are four kinds and am still 
> struggling to understand what I'm supposed
> to do with the wake lock.
>  
>
>>  Does your code hold a wake lock while playing the sound?
>>
>
> No, only when launching the intent.
>  
>
>>  You could also use a Notification with sound (perhaps as a test), I 
>> believe they take care of holding the device awake for themselves. Just make 
>> sure to post the notification from onReceive, while the system is holding a 
>> wake lock for you.
>>
>
> That means I have to learn all about notifications as I have never used 
> them before. So notifications hold the wake lock...
> I could use a notification and a pop up at the same time???
>
>

-- 
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

Reply via email to