0

I'm developing a web app for Samsung Gear using Tizen 2.4.

My app contains some widgets which the user can configure. Each widget instance will show different (dynamic) information based on the selected config.

Sadly the Galaxy Widgets don't retain their information on reboot. I have a widget which users can make several instances of, and each instance has it's own information.

Since I don't want my users to reconfigure each widget after each reboot, I decided to store the state information of each widget instance in the preferences file.

I thought I could simply use the widget instance id as a key. But I can't find a way to fetch it. The documentation also doesn't mention this. I noticed that there is a function called InstanceID() but I can't get it to work. Here is the widgets documentation

I was hoping to have a widget function such as tizen.widgetservice.getWidgetInstance().id which I could call inside the widget itsellf. But I can't find anything similar.

Is such a thing possible? How can I get the instance ID of the current widget itself?

Crude example about what I want to achieve below. (This is the desired widet code)

The index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<link rel="stylesheet" href="lib/tau.stripped.css" />
<!-- load theme file for your application -->
<link rel="stylesheet" href="css/style.css" />
<script src="language.js"></script>
</head>
<body>
<div id="content"></div>
</body>
</html>

The app.js

(function () {
function init() {
document.getElementById('content').textContent = tizen.widgetservice.getWidgetInstance().id;
}
window.onload = init();
}());

I do NOT want the Widget id, I want the INSTANCE id. So when 1 type of widget has 5 instances, I want to get 5 different ids.

Fabrizio Bertoglio
  • 5,890
  • 4
  • 16
  • 57
Gilles Lesire
  • 1,237
  • 17
  • 33
  • The link you provided is the correct documentation about what you are looking for. check _"Retrieving a Widget"_ and _"Retrieving ID and Size Information"_ and the followings on that page. – Towkir May 08 '19 at 06:53
  • Also, do you get any errors in the IDE console ? what is `window.Xonload = init();` supposed to do ? – Towkir May 08 '19 at 08:38
  • The script I gave is merely illustrative. No I don't have errors. I fixed the typo in the example above. The documentation only shows you a way to get the widget id. The name of the widget that is. That's the part I already know... Since you define that in your configuration file anyway. I want to get the INSTANCE id of the widget itself. As I already stated in my post. I want to get the unique identifier of each widget instance, so I can use that to store it's state in a persistent way so the user doesn't have to reconfigure his widget on every reboot. – Gilles Lesire May 08 '19 at 10:40
  • right, how about you console the instance of the widget. explore it and check if there is anything like that. – Towkir May 08 '19 at 12:19

0 Answers0