The persistence of registerReceiver() is tied to the context you are
calling it on.  For an Activity, it is active until the activity's
onDestroy() method returns.  For a Service, it is likewise active
until onDestroy().  For an Application, it is active for the life of
the process.

If you are wanting to do stuff in response to SMS messages, though, it
seems likely that you will want to be called even if your application
is not in for foreground?  If so, then you -must- register in the
manifest, so the system will know what you are interested in and be
able to launch you.

You are right, though, that we don't want to have a bunch of
applications launched even when they are not interested in some
particular data.  To this end, you can use the
PackageManager.setComponentEnabledSetting() method to disable your
IntentReceiver component when it is not needed:

http://code.google.com/android/reference/android/content/pm/PackageManager.html#setComponentEnabledSetting(android.content.ComponentName,%20int)

On Mar 30, 2:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> My application responds to various system-wide intents and what it
> responds to depends on the configuration of the user (e.g. the use can
> set whethere it should respond to incoming SMS or not, should respond
> to network tickles or not, etc).
>
> While I could just register all the handlers/receivers using the
> manifest. I feel that it would be a waste of cycles if every
> configurable handler gets registered via the manifest and in that
> handler, will do a check against the preference settings to see
> whether it should execute or not. So, I thought of assigning the
> handlers programatticaly instead, simply registering the needed
> handlers via Context.registerReceiver.
>
> My issue is, the documentation does not state how persistent is the
> Context.registerReceiver registry. That is, if the device gets
> rebooted, do I have to re-register the recievers again (i.e. have a
> service auto-start with the boot sequence which registers the
> handlers)?
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to