Wednesday, August 15, 2012

Re: [android-developers] Prevent garbage collection for Broadcast receiver that are dynamically registered

On Wed, Aug 15, 2012 at 12:34 PM, frantz lohier <flohier@gmail.com> wrote:
> Question: is there a way to ensure that receiver are programmatically
> registered at run-time are not deallocated when an app goes in background?

IMHO, a better implementation would be to register the receiver in the
manifest, then use PackageManager and setComponentEnabledSetting() to
control when it should and should not receive broadcasts. IMHO, a
receiver registered via registerReceiver() from an activity should
only be used for broadcasts while the activity is in the foreground.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.0 Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment