Tizen可穿戴设备如何使应用程序保持在前台? [英] Tizen wearable how to keep app in foreground?

查看:84
本文介绍了Tizen可穿戴设备如何使应用程序保持在前台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个检测按键操作的应用程序.我尝试了各种不同类型的应用程序,但均未成功. Tizen表盘不支持硬件密钥,由于没有接口,本机服务无法检测到硬件密钥. (如果我错了,请纠正我-但只有当您知道它现在在2.3.1上有效时,因为我看到了很多帖子,但似乎都没有用)

I'm trying to write an app that detects key presses. I have tried all kinds of different types of apps and no success. Tizen watchface does not support HW keys, native service can not detect HW keys because there is no interface. (correct me if i am wrong please - but only if you know it works right now on 2.3.1, because i saw a lot of posts but none seem to be working)

现在我正在使用webApp,它支持后台运行和硬件键.但是一段时间后,它总是会转到主屏幕(表盘),我该如何防止呢?毕竟,在任何情况下我都不能捕获Back键,这是我不希望隐藏它的原因,这一点非常关键.我的后退键无法关闭应用程序,所以没问题.

Right now i am working on webApp, that supports background running and HW keys. BUT after some time it always goes to home screen(watch face) How do i prevent that? It is very critical that i can capture Back key after all and any circumstances that is why i don't want it to hide. My back key does not close the app so that is no problem.

谢谢!真诚的罗克

p.s .: 并且如果有比WebApp更好的解决此问题的方法,请随时提出建议以在所有情况下都能捕获后退按钮.也许正在听W_HOME本机服务,该服务总是在按键时写入dlog.

p.s.: and if there is a better way for this problem than an webApp please feel free to suggest what to do to be able to capture back button under all situations. Maybe listening to W_HOME native service that always writes to dlog upon key presses.

推荐答案

您可以尝试以下步骤.它对我有用,因为当我的应用程序处于运行状态时,它无法显示外观.

You can try the following steps. It worked for me as it prevented from going to watch face when my app is in running state.

您需要注册侦听器以唤醒设备.当屏幕上可见时,然后重新启动您的应用.

You need to register listener for device wake up. When screen visible, then relaunch your app.

首先:您需要在config.xml中添加此权限

First: you need add this permission on your config.xml

 <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
 <tizen:privilege name="http://tizen.org/privilege/power"/>

第二:是的,您需要启用后台支持

Second: Yup, you need enable background-support

try {
  tizen.power.setScreenStateChangeListener(function(prevState, currState) {
   if (currState === 'SCREEN_NORMAL' && prevState === 'SCREEN_OFF') {
       //when screen woke up
       var app = tizen.application.getCurrentApplication();
       tizen.application.launch(app.appInfo.id, function(){
             //you can do something here when your app have been launch
       });
   }
  });
} catch (e) {}

请通过

Please go through this link for more details.

这篇关于Tizen可穿戴设备如何使应用程序保持在前台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆