Hello,
In my application I want to have launchers for all applications installed on the device. To do it I'm using code from Application API:
tizen.application.getAppsInfo(onGetApplicationsSuccess, onGetApplicationsError);
Gear S bug:
In the callback I have problem with first application - name is invalid, on my Gear S it's should be "Running" but is "Settings" (it also depends on language set on device) . All other applications have correct data.
Gear 2 bug:
On Gear 2 I have problem with S Voice launcher. All launchers work well, but after clicking S Voice launcher nothing happens.
Do you know how to fix these bugs?
I have created sample application with similar functionality, so you can test it on your devices:
index.html
<!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="Application API - Sample App"/> <title>Application API - Sample App</title> <link rel="stylesheet" type="text/css" href="css/style.css"/> <script type="text/javascript" src="js/lib/jquery-2.0.0.min.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div id="ui-container"></div> </body> </html>
style.css
body { margin: 0px auto; overflow: hidden; } #ui-container { position: relative; font-size: 28px; width: 320px; height: 320px; background: #000000; color: #ffffff; } #ui-container > div { position: absolute; top: 0px; left: 0px; width: 320px; height: 60px; } #ui-container > div > img { position: absolute; top: 10px; left: 10px; width: 40px; height: 40px; } #ui-container > div > div { position: absolute; top: 10px; left: 60px; width: 200px; height: 40px; line-height: 40px; } @media all and (min-width: 360px) { #ui-container { width: 360px; height: 480px; } #ui-container > div { width: 360px; } }
main.js
var applications = []; // APPLICATIONS function onGetApplicationsSuccess(tizenApps) { $('#ui-container').html(''); applications = []; var top = 0; var appid = 0; for (var i = 0; i < tizenApps.length; i++) { if (tizenApps[i].show == true && tizenApps[i].id != 'com.samsung.windicator') { //console.log(tizenApps[i].name); //console.log(tizenApps[i]); applications.push({'name': tizenApps[i].name.toUpperCase(), 'id': tizenApps[i].id}); var content = '<div data-appid="' + appid + '" style="top: ' + top + 'px;">'; content += '<img src="' + tizenApps[i].iconPath + '"/>'; content += '<div>' + tizenApps[i].name.toUpperCase() + '</div>'; content += '</div>' $('#ui-container').append(content); top += 60; appid += 1; } } $('#ui-container > div').unbind('click'); $('#ui-container > div').bind('click', function() { var appid = $(this).data('appid'); console.log(appid); console.log(applications[appid]); launchApplication(applications[appid]); }); } function onGetApplicationsError(error) { console.log(error.message); } function getInstalledApplications() { if (typeof tizen === 'object') { tizen.application.getAppsInfo(onGetApplicationsSuccess, onGetApplicationsError); } } // APPLICATION LAUNCH function onLaunchSuccess() { console.log("Application has launched successfully"); } function onLaunchError(error) { console.log(error.message); } function launchApplication(application) { if (typeof tizen === 'object') tizen.application.launch(application.id, onLaunchSuccess, onLaunchError); } window.onload = function () { // add eventListener for tizenhwkey document.addEventListener('tizenhwkey', function(e) { if(e.keyName == "back") tizen.application.getCurrentApplication().exit(); }); getInstalledApplications(); };
config.xml
<?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/ApplicationAPISampleApp" version="1.0.0" viewmodes="maximized"> <tizen:application id="PfBU3yxI4g.ApplicationAPISampleApp" package="PfBU3yxI4g" required_version="2.2"/> <content src="index.html"/> <feature name="http://tizen.org/feature/screen.size.all"/> <icon src="icon.png"/> <name>ApplicationAPISampleApp</name> <tizen:privilege name="http://tizen.org/privilege/content.read"/> <tizen:privilege name="http://tizen.org/privilege/content.write"/> <tizen:privilege name="http://tizen.org/privilege/system"/> <tizen:privilege name="http://tizen.org/privilege/application.launch"/> <tizen:privilege name="http://tizen.org/privilege/application.info"/> </widget>