i created a service in the onCreate i do some house work instantiate do some checks and so on.
Now the problem is when something goes wrong in the oncreate how do i cancel it or stop it or even throw a exception.
i already have a broadcast to tell the thing that started it or onbind it that something went wrong but how do i “Stop” it i tryed stopself but it does nothing.
thanks
A service that’s started with bindService will continue until the Context it’s called from is closed (i.e. Activity is finished) or unbindService(ServiceConnection) is called.
When something goes wrong in the onCreate of your service, call stopSelf(). Then, in the broadcast receiver back in your activity, call unbindService(ServiceConnection) and the service will be released and will stop.