preference and widget

david ashkenazi

New Member
Licensed User
Longtime User
I developed a widget (yet an other clock) with a preferecence screen.
The widget service is scheduled once a minute.

When I exit the preference, I do not get an event, so the widget apperance is modified and reflect the preference only after a minute.

Is there a way to overcomme this issue?
 

corwin42

Expert
Licensed User
Longtime User
Normally you will just start your service with StartService(servicename) to update your widget. But if you use the PreferenceActivity library (which is perhaps started from the widget service module itself) this is not directly possible (I think).

The only workaround I can think of would be to create a transparent activity which only calls the PreferenceActivity and then starts your service and exits on Activity_Resume.

Something like this (haven't tested it).
B4X:
Sub Activity_Create()
    OpenThePreferenceScreenHere
End Sub

Sub Activity_Resume()
    StartService(servicename)
    Activity.Finish
End Sub
 
Upvote 0
Top