Languages

Menu
Sites
Language
Wearable: Multiple instances of the same Widget, how to save different config for each of them?

Hi, I'm creating an wearable application which should provide a user configurable widget. So a user can add the widget and once added choose from a list of items, which one he would like to see on this widget. He then can add another one with a different item. The princible is similar to a weather widget: The user can add the same widget multiple times but with a different location on each.

I have followed this blog post: https://developer.samsung.com/tizen/blog/en-us/2019/12/02/build-a-widget-for-galaxy-watch

And it's working, I can add the widget multiple times. But how can I know in the OnCreate method of the "MyWidgetBase"-Class which widget it currently is so the correct config can be loaded? Is there some sort of persistent ID or similar? So once the user has configured I could save the ID together with the config in the preferences. I have read there is an ID but it is not persistent across reboots but I even could not find how to get this ID in my .NET App, only in Web and Native.

But I'm 100% sure there must be some persistent way, as the preinstalled Samsung Apps can do exactly what I wan't. For example you can add the "Alarm"-Widget multiple times and select a different alarm time on each. The correct time is persistent across reboots. So how I can achieve exactly this behaviour in my .NET Widget Application?

Sadly the docs are very incomplete in that topic, the only guide for .NET Wearable Widgets I've found is the mentioned blog post...

Thanks in advance

Responses

1 Replies
Tizen .NET

Hi,
You can save the current state of the widget instance via SetContent(Bundle info).
(This Bundle info will be saved by viewer(home) app when the widget instance is terminated)
When viewer(home app) needs to restore the widget instance again, the information is transmitted via content parameter of OnCreate(Bundle content, int w, int h).
This Bundle content contains the data you most recently save through SetContent(). You can restore the UI state for each widget instance.
Thanks.