I am using Service to do long running process. I bind the service in activity to initiate the process. Below is the code which binds the service.
val intent = Intent(context,SaveSessionService::class.java)
context.bindService(intent, mSaveSessServiceConnection, AppCompatActivity.BIND_AUTO_CREATE)
After the service finishes at the background, I am trying to stop the service. I am using stopService(). But I am getting activity leaking service connection error. After doing some reading on SO Questions, came to know that when service is bound with BIND_AUTO_CREATE, we can't stop the service with stopService.
My Question is how can I connect with the service as I also read that calling startService for long running service is also not advisable. Is it better to use IntentService (I don't think so as only Service should be used for long running task as per the documentation)?
I can't reference back to activity, once I goto service. I should be able to stop the service from service itself.
So with this use case, which is better, to start a service with startService or use IntentService?