On Fri, Mar 18, 2011 at 12:48 PM, Jake Colman <[email protected]> wrote: > What about, for example, a Stop Watch app that counts every tenth of a > second to be used as a lap timer. Is that ok because it is an activity > and not a broadcast receiver?
Done correctly, yes. > If so, why? 1. Because an activity does not intrinsically involve inter-process communication. App widgets do. 2. App widgets are implemented as manifest-registered BroadcastReceivers, which are short-lived components, whereas an activity lives as long as the user wants it. Short-lived components have greater restrictions on what they can safely do (e.g., fork a background thread). 3. Activities live as long as the user wants them. App widgets -- in terms of their on-screen representation -- live forever (until the user removes them). People trying to develop digital clock app widgets then fall into the trap of trying to have an everlasting service, and everlasting services are generally an anti-pattern on Android. There may be other reasons, but those should do for now. -- 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 *Advanced* Android Development_ Version 1.9 Available! -- 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

