Search code examples
servicebasic4android

Stop httputils service in basic4android


I am using basic4android and I made an application that uses httputils services. Sometimes a remote error occurs (possible server overload or limited internet connection) and the application exits with the error message box. The activity closes but httputils service is still running. While I reopen the activity new error occurs, because of the unfinished job of httputils. Everything is OK only if I choose to stop the activity in the second error. Is there any way to determine if the httputils service is running by a previous instance of my app? Or better, a way to try to stop this service either its running or not.


Solution

  • HttpUtils errors should not cause your program to exit. You should check IsSuccess to make sure that the call succeeded or not.

    You can stop the service from running by calling StopService(HttpUtilsService).