Yes sorry, bad wording, not an activity as such.

My AlarmReceiver has one method, onReceive(), which starts an
ASyncTask - that in turn does a server call, then schedules the next
alarm.

On Feb 24, 8:50 pm, Kostya Vasilyev <[email protected]> wrote:
> Ok, that's a receiver.
>
> I am guessing that your receiver uses startActivity. If you do that,
> beware of sleep/wake states, it's documented here:
>
> http://developer.android.com/reference/android/app/AlarmManager.html
>
> Android guarantees that for Wakeup-type alarms delivered to a broadcast
> receiver, it will keep the device from falling back to sleep only for
> the duration of the receiver's onReceive.
>
> If that's too short, and your code needs to do more, especially an
> asynchronous operation (such as starting an Activity or a Service), then
> it's up to your code to acquire a WakeLock to keep the device awake as
> long as needed for that.
>
> There is an example at the top of this page:
>
> http://developer.android.com/reference/android/os/PowerManager.html
>
> Basically, the structure should be -
>
> onReceive()
>      Call startService or startActivity
>      Acquire a WakeLock
> [return]
> --- lock is held, device is still awake ---
> Android processes "startActivity" call
> Your activity is created and started
> onResume releases the wake lock so it's not held forever
>
> Somewhere in there should be some kind of error handling, so that if
> something goes wrong, the device is not held awake indefinitely (or
> rather, until the battery runs out - which won't be long).
>
> -- Kostya
>
> 24.02.2011 23:27, Neilz пишет:
>
>
>
> > Like this:
>
> > public class AlarmReceiver extends BroadcastReceiver {
>
> > On Feb 23, 10:11 pm, Kostya Vasilyev<[email protected]>  wrote:
> >> 24.02.2011 1:06,Neilzпишет:
>
> >>>    I'm using an Activity that
> >>> extends a BroadcastReceiver...
> >> An Activity that extends a Broadcast receiver? Sorry, I'm not sure I
> >> understand what this means.
>
> >> Do you mean something else - like a BroadcastReceiver subclass that
> >> starts an Activity subclass?
>
> >> --
> >> Kostya Vasilyev --http://kmansoft.wordpress.com
>
> --
> Kostya Vasilyev --http://kmansoft.wordpress.com

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