Service onCreate() is not being called

348 Views Asked by At

I have a activty A and after a button click I am starting another activity B in which I am starting a service using bindService as below:

Intent intent = new Intent(context, RadioService.class); context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);

During this the onCreate() of the service class is being called. Now when I close the activity B inside onDestroy() of B I am stopping the service as below:

context.unbindService(serviceConnection);

The problem that I am facing is second time if I enter the activity B the service class onCreate() is not being called. Why is so that the case? What can be done as I want the onCreate() to be called.

1

There are 1 best solutions below

0
bhaskar On

I solved it by calling startService() before bindService().