<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="Tizen Web UI Service Application Template" />

  <title>Tizen Web UI Service Application Template</title>

  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <script src="js/main.js"></script>
  <script type="module">
  import * as service from 'wrt:service';
  var pkg_id = tizen.application.getCurrentApplication().appInfo.packageId;
  function startService() {
    service.startService(pkg_id + ".Service").then(function() {
      console.log("Succeeded to launch");
      alert("Succeeded to launch");
    }, function(error) {
      console.log("Please check already running service " + error);
      alert("Please check already running service " + error);
    });
  }
  function stopService() {
    service.stopService(pkg_id + ".Service").then(function() {
      console.log("Succeeded to stop service");
      alert("Succeeded to stop service");
    }, function(error) {
      console.log("There's no running service " + error);
      alert("There's no running service " + error);
    });
  }
  document.querySelector('#start_service').addEventListener('click', startService);
  document.querySelector('#stop_service').addEventListener('click', stopService);
  </script>
</head>

<body>
  <div id="main" class="page">
    <div class="contents">
      <span>
        <button id="start_service" class="service_button">Start service</button>
      </span>
      <span>
        <button id="stop_service" class="service_button">Stop service</button>
      </span>
    </div>
  </div>
</body>

</html>
