Clickable text not working to launch messaging app on Tizen watch

Original Created Jun 17, 2019 | Regeneration Apr 22, 2026

I'm trying to create a simple Tizen watch application where clicking on text should launch the messaging app. However, my implementation isn't working. Here's my code:

index.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <script src="js/main.js"></script> 
</head>
<body>
  <div id="page">    
    <p id="para">Launch Messaging</p> 
  </div>
</body>
</html>

main.js:

(function() {
  function launchApp() {
    tizen.application.launch("com.samsung.message");
  }

  function init() {
    window.getElementById('page').addEventListener('click', launchApp);
  }

  window.onload = init();
}());

What am I missing? Why isn't the click event working to launch the messaging app?

Problem Understanding

The issue appears to be with the event listener setup and application launch implementation. There are several potential problems:

  1. The event listener might not be properly attached
  2. The application ID might be incorrect
  3. The necessary privilege might be missing in config.xml

Solution Methods

  1. Verify Application ID: First, confirm the correct application ID for the messaging app by listing all installed applications.

  2. Check Privileges: Ensure your config.xml includes the required privilege for launching applications.

  3. Proper Event Handling: Correct the event listener implementation and add error handling.

Code Examples

Listing installed applications:

function onListInstalledApps(applications) {
  for (var i = 0; i < applications.length; i++) {
    console.log("ID: " + applications[i].id);
  }
}

tizen.application.getAppsInfo(onListInstalledApps);

Corrected main.js with error handling:

(function() {
  function launchApp() {
    try {
      tizen.application.launch("com.samsung.message");
    } catch (error) {
      console.error("Failed to launch app: " + error.message);
    }
  }

  function init() {
    document.getElementById('page').addEventListener('click', launchApp);
  }

  window.onload = init;
}());

Additional Tips

  1. Make sure your config.xml includes:

    <privilege>http://tizen.org/privilege/application.launch</privilege>
    
  2. Use document instead of window for DOM operations.

  3. Don't call init() directly in window.onload - just assign the function reference.

  4. Test your application on an actual device as some features might not work in the emulator.

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.