Languages

Menu
Sites
Language
[Gear] Problem with Application API

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>

 

View Selected Answer

Responses

4 Replies
daniel kim

Hi,

For Gear S, Nike running application is using <ns2:name> tag for the name in the config.xml. I think that there is no way to fix it in application side. How about you manually convert wrong name of "Running" in case of this application only when you display it to screen? 

And about S voice of Gear 2, I could run it using your sample after S voice is enabled in the device side.

Regards,

von wolfchen

Hi, thank you for answer.

I'm able to convert name manually, but some languages (e.g. Chinese - certification team sent me screenshot with "bug") use translated names of applications (but e.g. when Polish is set then all names are still in English)! oO

Currently I'm waiting for a response from Certification team (I've informed them about this bug), so soon will I know if my application with the appropriate comment will be available in Gear Apps.

Mark as answer
Gunwang Jeong

Hi,

In case of application name, There is a getAppInfo() API to get it from device.
If you are using getAppInfo API, you can get correct application name in Gear S.


Please refer below sample code.

var appInfo = [];
function application() {
 try {
  tizen.application.getAppsInfo(function(info){
   for (var i in info) {
    if (info[i].show) {
     appInfo.push({'name' : tizen.application.getAppInfo(info[i].id).name.toUpperCase(),  'id' : info[i].id});
    }
   }
  }, function(e){
   console.log(e.name + " " + e.message);
  });
 } catch (e) {
  console.log(e.name + " " + e.message);
 }
}

 

von wolfchen

Wow! Thank you very much, now names are correct :)