How to check if a widget is placed on homescreen

corwin42

Expert
Licensed User
Longtime User
I often want to update a homescreen widget from an activity or another service (not the widget service). For example if I want to change some settings which affect the widget.

The only way I see to do this is to call StartService(widgetservice). In the Service_Start Sub I check the StartingIntent.Action and if it is empty it probably was called manually by StartService() and this is my manual update.

Now I only want to start the service if a widget is really placed on the homescreen. Alternatively I can stop the service again when no homescreen widget is active but I didn't find a reliable way to check if a widget is placed on the homescreen or not.

I tried to set a process global variable in rv_RequestUpdate and clear it in rv_Disabled but this does not work reliable because the process can be killed by the system sometime even when the widget is active.

I didn't find a reliable solution to check if a widget is active or not. Any ideas?
 
Top