Why disable the onDestroy Service?

I saw that it is mentioned in many sources that if Activity binds a service, it should cancel it onDestroy. What for? Since the action is destroyed, it looks like the service will still be disabled. If it was "launched" - it does not matter. And if it was automatically started by activity - it will still close if others do not bind it.

So why untie it?

+4
source share
1 answer

Actions must handle configuration changes, for example, when the screen is rotated or the user changes locales, or the device enters night mode.

, , , .

bindService() Activity . , . ( , ).

, - bindService() Application. ServiceConnection . , unbindService() onDestroy() , , "" (, BACK, finish()), .


, .

-, , , bindService(), Activity. , , , , , .

, bindService() Activity . , .

, call- bindService() -on-the- Application, , - - , Application . , unbindService() - (, onDestroy() ), .

+6

Source: https://habr.com/ru/post/1669082/


All Articles