Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-24 Thread John Goche
On Mon, Oct 24, 2011 at 1:57 AM, John Goche johngoch...@googlemail.comwrote: Well, here is what I am doing now: I acquire a wakelock inside the broadcast receiver and release it from my activity. The only problem I have is that the play() method is asynchronous. I would like to be notified

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-24 Thread Studio LFP
Have you considered using a MediaPlayer instead of just a straight Ringtone object? You can pass the URI of the Ringtone to the MediaPlayer and have better functionality. I use the MediaPlayer and create a MediaPlayer.OnCompletionListener to watch for the end of the playing. This doesn't

[android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread Ali Chousein
What does cal.getTimeInMillis() in the following statement return? Maybe the problem is there. alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent); I use the following statement while setting alarms: this.am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread John Goche
Thank you for your reply but cal.getTimeInMillis() returns the right thing. It has been suggested before that this might be returning the wrong value but whenever I attach my device via USB cable I always see all alarms being set as you can see one of them below (others omitted). I regret that I

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread Kostya Vasilyev
Not sure why you use a static PendingIntent - if it's for optimization reasons, that's really not necessary. I wonder if that, by itself, could cause the behavior you're describing. You can use dumpsys alarm in adb shell to see the actual alarms set in the system, and verify that your code

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread John Goche
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:

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread Studio LFP
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

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread Kostya Vasilyev
I would still recommend you repeat your test with a Notification (possibly with a sound), as the system should take care of holding the wake lock(s) as needed for the duration of the sound. As for implementing the wake locks in your code, to display an alert: First, take a look at the docs,

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread John Goche
Thanks Kostya, I changed my wakelock from partial wakelock to full wakelock and that seems to have fixed things, albeit somewhat strangely. I now see the screen light up on each timer expiration. I am going to do some more testing and if things go wrong I will try releasing the wakelock from

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread John Goche
Hi, I have done some more testing. It is working much better now in that each time there is an alarm a window pops up. In one last case though only after sliding the phone guard up I did find that the alarm window started to play late, so it is as though indeed the phone went back to sleep right

Re: [android-developers] Re: alarm type application: alarm manager not waking up application

2011-10-23 Thread John Goche
Well, here is what I am doing now: I acquire a wakelock inside the broadcast receiver and release it from my activity. The only problem I have is that the play() method is asynchronous. I would like to be notified when the sound stops playing via a callback but I see no method for doing so here: