Gil*_*ire 1 javascript tizen tizen-web-app samsung-galaxy-gear
我正在为 Samsung Gear 开发 Tizen Web 应用程序。(使用 Tizen 2.4)
目前我尝试添加一个功能,允许用户通过手表打开手机上的链接。因此,当他按下按钮时,手机的默认浏览器中将打开一个 URL。我注意到其他智能手表应用程序也有此功能。
浏览这些论坛后,我找到了一个代码示例:
var appControl = new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/view',
'https://www.tizen.org', null, null, null, null);
tizen.application.launchAppControl(appControl, null, function() {
console.log('launch application control succeed');
}, function(e) {
console.log('launch application control failed. reason: ' + e.message);
}, null);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行它时,出现以下错误:"launch application control failed. reason: No matched application found."
我的应用程序在其配置文件中添加了以下权限:
<tizen:privilege name="http://tizen.org/privilege/application.info"/>
<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
Run Code Online (Sandbox Code Playgroud)
找到它您将需要 application.launch 权限。
function openBrowserOnPhone(url) {
var appid = "com.samsung.w-manager-service";
var type = "phone";
var extra_data = [
new tizen.ApplicationControlData("msgId", ["mgr_install_host_app_req"]),
new tizen.ApplicationControlData("type", [type]),
new tizen.ApplicationControlData("deeplink", [url])];
var appControl = new tizen.ApplicationControl(
"http://tizen.org/appcontrol/operation/default",
null,
null,
null,
extra_data);
var appControlReplyCallback = {
onsuccess: function(data) {
console.log("launchUrl reply success");
console.log("success: data = " + JSON.stringify(data));
},
onfailure: function() {
console.log("launchUrl reply failed");
}
};
try {
tizen.application.launchAppControl(
appControl,
appid,
function() { console.log("intentBorba", "launchUrl success"); },
function(err) { console.log("intentBorba", "launchUrl failed: " + err.message); },
appControlReplyCallback);
}catch(err) {
console.error("[launcher] " + err);
}
}
Run Code Online (Sandbox Code Playgroud)