You need to hold a wake lock the entire time you want to be running, from
when onReceiveIntent() is called until you have done all of your work.

On Tue, Nov 18, 2008 at 9:56 PM, Adam K <[EMAIL PROTECTED]> wrote:

> Thanks Dianne.
>
> Should I be holding a wakelock in the pendingintent receiver of the
> alarm (basically acquiring at the start of the onReceive() and
> releasing at the end)?  All I am doing in the receiver is setting off
> a notification - I am not creating any other intents or accessing any
> other threads or services.
>
> Cheers,
>
> Adam
>
> On Tue, Nov 18, 2008 at 9:22 PM, Dianne Hackbod <[EMAIL PROTECTED]>wrote:
>
>> Fwiw, I am not aware of any issues with the alarm itself not waking up the
>> phone.  Typically bugs in this area are a result of applications not holding
>> wake locks the entire time needed.
>>
>> Note that the behavior when not holding a wake lock can change
>> significantly between devices, depending on things like how often sync is
>> running.
>>
>>
>> On Tue, Nov 18, 2008 at 6:15 PM, Adam K <[EMAIL PROTECTED]>wrote:
>>
>>>
>>> Ping.  Anyone?  It seems for certain people the alarm can never wake
>>> up the phone.  For others (like myself) it pretty much always wakes up
>>> the phone.
>>>
>>> Thanks,
>>>
>>> Adam
>>>
>>> On Nov 16, 8:15 pm, "Adam K" <[EMAIL PROTECTED]> wrote:
>>> > Hi all,
>>> >
>>> > I noticed that AlarmManager does not always seem to wake the device
>>> > correctly when using types RTC_WAKEUP or ELAPSED_REALTIME_WAKEUP.  It
>>> > seems like whatever intent was pending is triggered later after the
>>> > Menu key is hit.
>>> >
>>> > I realize you need to hold a wakelock for any activity fired after the
>>> > initial pending intent event - but I thought at least the pending
>>> > intent should execute without a wakelock being required?  All I want
>>> > to do is set off a Notification when the alarm is complete - nothing
>>> > else.
>>> >
>>> > It does seem to work 90% of the time without an issue, just not 100%
>>> > of the time.  Has anyone else noticed this?
>>> >
>>> > Here is a summarized version of what I'm doing:
>>> >
>>> > //in main activity, set alarm for some time in future
>>> > myPendingIntent = PendingIntent.getBroadcast(myContext, 0, new
>>> > Intent(myContext, MyReceiver.class), 0);
>>> > myAM = (AlarmManager) getSystemService(ALARM_SERVICE);
>>> > myAM.set(AlarmManager.RTC_WAKEUP, getTriggerTime(), myPendingIntent);
>>> >
>>> > //in MyReceiver.class, onReceiver(), trigger notification
>>> > NotificationManager myNM = (NotificationManager)
>>> > context.getSystemService(Context.NOTIFICATION_SERVICE);
>>> > Notification notif = new Notification();
>>> > ..setup notification to play alarm, vibrate etc.
>>> > myNM.notify(MYNOTIFICATION_ID, notif);
>>> >
>>> > Thanks,
>>> >
>>> > Adam
>>>
>>>
>>
>>
>> --
>> Dianne Hackborn
>> [EMAIL PROTECTED]
>>
>>
>>
>>
>>
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[EMAIL PROTECTED]

Note: please don't send private questions to me, as I don't have time to
provide private support.  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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to