简体   繁体   English

Tizen可穿戴设备如何使应用程序处于前台?

[英]Tizen wearable how to keep app in foreground?

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. Tizen表盘不支持硬件密钥,由于没有接口,本机服务无法检测到硬件密钥。 (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) (如果我错了,请纠正我-但只有当您知道它现在在2.3.1上有效时,因为我看到了很多帖子,但似乎都没有用)

Right now i am working on webApp, that supports background running and HW keys. 现在,我正在使用webApp,它支持后台运行和硬件键。 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. 毕竟,在任何情况下我都不能捕获Back键,这是我不希望隐藏它的原因,这一点至关重要。 My back key does not close the app so that is no problem. 我的后退键无法关闭应用程序,所以没有问题。

THANK YOU! 谢谢! Sincerely Rok 真诚的韩

ps: 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. ps:如果解决此问题的方法比使用webApp更好,请随时提出建议以在所有情况下都能捕获后退按钮。 Maybe listening to W_HOME native service that always writes to dlog upon key presses. 也许正在听W_HOME本机服务,该服务总是在按键时写入dlog。

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. 当屏幕可见时,然后重新启动您的应用程序。

First: you need add this permission on your config.xml 首先:您需要在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. 请通过此链接获取更多详细信息。

Why don't you try to use power api? 您为什么不尝试使用Power API? In truth, I didn't test it yet. 实际上,我还没有测试。 But I think if you block go to sleep state, it also will not go to home(watchface). 但是我认为,如果您阻止进入睡眠状态,它也不会回家(表面)。

Good luck to you! 祝你好运!

https://developer.tizen.org/dev-guide/2.4/org.tizen.web.apireference/html/device_api/mobile/tizen/power.html https://developer.tizen.org/dev-guide/2.4/org.tizen.web.apireference/html/device_api/mobile/tizen/power.html

1.3. 1.3。 PowerCpuState 电源状态

Specifies the power state for the CPU resource. 指定CPU资源的电源状态。 enum PowerCpuState { "CPU_AWAKE" }; 枚举PowerCpuState {“ CPU_AWAKE”}; Since: 2.0 从:2.0

The supported values are: 支持的值为:

CPU_AWAKE - The CPU state is set to awake and it does not go to SLEEP state automatically. CPU_AWAKE-CPU状态设置为唤醒,并且不会自动进入SLEEP状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TIZEN硬件按钮BACK-MENU…如何编程 - TIZEN Hardware Buttons BACK - MENU … How to program SWIFTUI - 如何在带有单独视图问题的测验应用程序中保持分数? - SWIFTUI - How to keep score in a quiz app with questions on separate views? 如何在Unity运行时将图像带到前台? - How to bring an image to the Foreground on run time in Unity? 如何设置Button的悬停和单击前景的样式? - How To Style Button's Hover And Click Foreground? Windows 8 Metro应用程序按钮前景色和背景色的行为 - Windows 8 metro app button behavior of foreground and background color 按下和释放时如何更改按钮的前景和背景 - How to Change Button Foreground and Background When Pressed and Released 如何在 Mac OS X 上更改 Tkinter 按钮的前景色或背景色? - How to change the foreground or background colour of a Tkinter Button on Mac OS X? 如何将按钮的背景颜色与另一个项目的前景匹配 - How can i match the background color of a button with the foreground of another item 如何更改 MahApps 中所有命令按钮的前景色 - How to change the foreground color of all command buttons in MahApps 如何使用 javascript 添加背景色和前景色 - How to add background color and foreground color using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM