why shouldnt startservice/stopservice instead of bind/unbinding to the service
On Mon, Jun 4, 2012 at 3:15 PM, Kostya Vasilyev <kmans...@gmail.com> wrote: > > 04.06.2012 13:06, Greenhand написал: > > I modify my code and use bindService(new >> Intent(getApplicationContext()**, MessengerService.class), mConnection, >> Context.BIND_AUTO_CREATE) but my service still be killed and created >> with my Activity life cycle. Can you please illustrate "Don't unbind >> in the old activity instance -- only unbind from the new one." more >> clearly, such as some code fragments? >> > > Don't unbind from the activity that's going away during rotation. > > Use onRetainNonConfigurationInstan**ce / getLastNonConfigurationInstanc**e > to carry the service connection over from the "portrait" activity instance > to the "landscape" activity instance. > > Unbind as usual when the second, rotated, instance gets destroyed. > > > I have never used a fragement. Is it different from Activity when it >> comes to handling bound service on rotation? >> > > If you bind to the service from a fragment, you can have the framework > retain the fragment on rotation by setting fragment.setRetainInstance(**true), > rather than using the two Activity methods with unpronounceable names, > above. > > -- K > > > -- > 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<android-developers@googlegroups.com> > To unsubscribe from this group, send email to > android-developers+**unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en> > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en