When you define a <receiver> in the manifest, the system will force
your process awake to handle those broadcasts, even when your process
may not be running.

The overhead of ramping up a new process every time the user turns
on/off the display is very high, which is why you want to avoid it.
But in his case it's cheap when his Service is already running.

j


On Fri, May 29, 2009 at 1:37 PM, clemsongrad <[email protected]> wrote:
>
>
> Jeff,
>
> What would the behavior be if you registered the broadcast receiver
> and listed these intents in the manifest?
>
> Would the run time start the service to invoke the onReceive()
> method?   If so this is a great tip for optimization.
>
> Thanks
>
> On May 29, 1:38 pm, Jeff Sharkey <[email protected]> wrote:
>> > I've dug through the documentation but couldn't find a call that would
>> > fit: Is there a way to find out the screen status (Active/dark)?
>>
>> You can listen for Intent.ACTION_SCREEN_OFF and ACTION_SCREEN_ON
>> broadcasts.  However, I would strongly recommend registering for these
>> dynamically at runtime using Context.registerReceiver().  This ensures
>> that you'll only receive the broadcasts if your Service is already
>> awake, which is what you want.  :)
>>
>> --
>> Jeff Sharkey
>> [email protected]
> >
>



-- 
Jeff Sharkey
[email protected]

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