Triggering a web application from a widget on my smartwatch, packaged in the same folder structure

Hi, I’ve managed to connect my Galaxy smartwatch to the Tizen IDE and create my first (simple) application, which I can upload to my watch. Hurrah ! I want to go to the next level and create a beautiful widget that includes a call to action to open my web application, but I can’t work out how to do this - can anyone out there help ? Looking at the widgets bundled with my smartwatch, it seems to be fairly standard functionality to have a button to open an application, or more often to open a specific feature within an application.

I have used the “widget” application template, which creates a basic web app providing user instructions on how to set up the widget and provides the application itself - both are included in the file structure. I originally tried a standard tag, to link back up a level from the widget directory, back to the application that it is part of; but that doesn’t work. <a href="…/…/index.html>link text.

I then looked into using a script such as tizen.application.launch, but I can’t make that work either. Do I need any special privileges within the config.xml ???

I am hoping that the kind developer community will be able to help …

Many thanks, in advance,

Jon M

Hello,
Please check below code,

If no alarm exists, the widget displays the Add alarm button. When the user clicks it, the alarm application is launched:


function launchWebApp()
{
   var app = window.tizen.application.getCurrentApplication();;
   var appId = app.appInfo.id.substring(0, (app.appInfo.id.lastIndexOf('.')));
   window.tizen.application.launch(appId);
}

var addAlarm = document.getElementById('add-alarm');
addAlarm.addEventListener('click', launchWebApp);
If an alarm exists, it is displayed.
The widget includes a layout for both a one-time and repeat alarm type. The view is controlled based on the alarm data by using the display property. When one alarm type is displayed, the other's display property is set to none.

/* Get alarm data, which sets the alarm type */
var alarmData = getAlarmData();
time.textContent = alarmData.time;
am_pm.textContent = alarmData.amPm;

if (alarmData.type === 'repeat')
{
   sun.style.color = alarmData.sun === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   mon.style.color = alarmData.mon === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   tue.style.color = alarmData.tue === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   wed.style.color = alarmData.wed === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   thu.style.color = alarmData.thu === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   fri.style.color = alarmData.fri === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   sat.style.color = alarmData.sat === true ? 'rgb(77, 207, 255)' : 'rgb(184, 184, 184)';
   oneTimeAlarm.style.display = 'none';
   repeatAlarm.style.display = 'block';
}
else
{
   date.textContent = alarmData.value;
   oneTimeAlarm.style.display = 'block';
   repeatAlarm.style.display = 'none';
}

Check full source code here, Tizen Docs

More sample apps: Tizen Docs

Thank you,
Iqbal