Binding to Android service

A bound service is the service that allows Android components to bind to it. To perform binding, we must call the bindService() method. When you want to interact with the service from activities or other Android components, service binding is necessary. For bind to work, you must implement the onBind() method and return an IBinder instance. If there are no interested parties anymore, and all of them are unbound, Android destroys the service. For this type of service, you do not need to perform the stop routine.

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.