I iCAB Well-Known Member Licensed User Longtime User Jul 5, 2015 #1 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 Code: #Region Service Attributes#StartAtBoot: false#StartCommandReturnValue: android.app.Service.START_STICKY#End Region Code: Sub Activity_DestroyTry StopService(WSPushService)Log( "destroyed" ) Catch Log(LastException) EndTry End Sub I have also commented out: StartServiceAt in Service_Start
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 Code: #Region Service Attributes#StartAtBoot: false#StartCommandReturnValue: android.app.Service.START_STICKY#End Region Code: Sub Activity_DestroyTry StopService(WSPushService)Log( "destroyed" ) Catch Log(LastException) EndTry End Sub I have also commented out: StartServiceAt in Service_Start
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2015 #2 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? Upvote 0
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?
I iCAB Well-Known Member Licensed User Longtime User Jul 6, 2015 #3 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. Upvote 0
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.
Erel B4X founder Staff member Licensed User Longtime User Jul 7, 2015 #4 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. Upvote 0
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.
I iCAB Well-Known Member Licensed User Longtime User Jul 8, 2015 #5 Stopping the timer did the job. Thank you Upvote 0