On Tue, Nov 2, 2010 at 2:54 PM, jotobjects <[email protected]> wrote: > I have tried both startService() and bindService(). Both methods > return before Service.onCreate() is called. So work I was expecting > to complete in Service.onCreate() is not done.
It is not done by the time startService() or bindService() return. It is not supposed to be done by then. Android will not have even begun to start the service by the time those methods return (except bindService(), if the service is already running). This is no different than startActivity(), in that regard. > Is it necessary to do initialization steps in the Service > constructor? If so what use is the Service.onCreate method? Any > suggestions about how others handle this problem? What problem? > Further even the Service constructor is called asynchronously. Correct. > It looks like all operations on a Local Service have to go through the > ServiceConnection, or at least operations on the service have to be > deferred until after onServiceConnected has been called. Is that > correct? If you are using the local binding pattern, you need to wait until onServiceConnected() -- until then, you are not bound. startService() is more for the command pattern, where the activity should not depend upon when the service does what it does. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android 2.2 Programming Books: http://commonsware.com/books -- 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

