Zombie widget service, just wont die!

JohnK

Active Member
Licensed User
Longtime User
I have a widget that just will not die!

I have
B4X:
Sub rv_Disabled
    Log(">>STOP SERVICE")
   StopService("")
End Sub
which does not appear to be called? (I also have a "Service_destroy" similar to the above.)

When I do delete the widget from my homescreen, I can see in the logs that "** Service (widgetservice) Destroy **" does get called, but not ""rv_Disabled".

Any ideas as to what is going wrong? or a workaround to kill the zombie widget when it is removed from the homescreen?
 
Last edited:

corwin42

Expert
Licensed User
Longtime User
Are you rescheduling the widget service manually with StartServiceAt? If yes look here how to stop the service correctly.

Otherwise I think you should post your widget code here or better attach a complete project that shows the problem.
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
I just tested it and rv_Disabled is called as expected.
Try to remove the sub completely and see whether the service is destroyed.
I Commented out rv_Disable & Service_Destroy, and the service lived on after I removed it from the home screen.

Are you rescheduling the widget service manually with StartServiceAt? If yes look here how to stop the service correctly.
Thanks, but this does not help, as rv_Disable is not being called.

And to add to the mix, if I re boot my phone, the service will be started, even though the widget is not on my homescreen.
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
Previously it was NOT being called when it was not commented.

OK, I don't know what I did (Commented out the two subs, compiled, un-commented, re-compile), or how I did it, but it is now calling the subs rv_Disable and Service_Destroy.

When I look at the running processes after I remove the widget, there is no longer a running service. However, there is now still 1 Process. Previously, and now when the widget is actually used, there is 1 Process & 1 Service. My Configure activity is closed with an "Activity.Finish". Should I be doing more?
 
Upvote 0
Top