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
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
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,
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
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
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:
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
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,
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
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
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:
11 matches
Mail list logo