> The overiding problem for me is that the behaviours I described above > are causing different scenarios with my service. When I press 'back', > and then return to the activity, a new connection to the service is > created. Which results later in the service not being destoyed when I > tell it to, because there is the old connection still hanging around. > (Then, depending on user actions, I can get a leak error). > > Why am I using bindService()? Well I thought I had to, I'm using an > aidl file with methods implemented to get stuff from the service...
If this is a local service (i.e., the activity and the service are in the same project), you do not need AIDL. Use the local binder pattern, found in the APIDemos, or another variant here: http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/ You probably want to bind in onStart() and unbind in onStop(). Remember that the service will run *either* if you are bound to it *or* if somebody called startService() without a corresponding stopService()/stopSelf(). If you bind in onStart() and unbind in onStop(), then your HOME button press will unbind from the service...which will either shut down (if the user didn't press Play or whatever is triggering startService()) or not (if startService() indeed was called). -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html -- 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

