Android Question Terminating WebSocket PushService Properly

Discussion in 'Android Questions' started by iCAB, Jul 5, 2015.

  1. iCAB

    iCAB Well-Known Member Licensed User

    I am facing some difficulties after adding Websocket Push Services code to my application. I particular
    I started getting "Unfortunately ProgramName has stopped" after terminating the app.
    The issue is due to some uninitialized variables that are being access by the Service ( please note that there is no issue while the application is running as all these variables are initialized proper during run time ).
    I am not sure what I am doing wrong in here, but here is what I have done so far to terminate the service when the application is terminated

    #Region Service Attributes#StartAtBoot: false#StartCommandReturnValue: Region
    Sub Activity_DestroyTry
    StopService(WSPushService)Log( "destroyed" )
    End Sub
    I have also commented out: StartServiceAt in Service_Start
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    Don't you want to receive push messages when your app is in the background?
  3. iCAB

    iCAB Well-Known Member Licensed User

    The perfect scenario will be to receive push notifications when the app is in the background, but not after it is terminated by the user.
    Once the user closes the app, I don't want to receive the messages in this particular app.
  4. Erel

    Erel Administrator Staff Member Licensed User

    I think that it is better to use a service to manage the push messages. It will be simpler.

    Make sure that the service is not a sticky service, it doesn't start at boot and remove the StartServiceAt calls.

    You should also stop the timers when the service is destroyed.
  5. iCAB

    iCAB Well-Known Member Licensed User

    Stopping the timer did the job.
    Thank you
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice