Tizen 应用程序振动背景 [英] Tizen app vibration background

查看:40
本文介绍了Tizen 应用程序振动背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三星 Gear S,我正在忙着编写一个网络应用程序.当我从我的服务器收到消息时,我想振动我的应用程序.我只是使用 navigator.vibrate(1000) 并且这很好用.但是当我的应用程序进入后台时,振动不再起作用.我找到了这个线程(https://developer.tizen.org/ko/forums/web-application-development/vibration-background?langswitch=ko),其中他们面临同样的问题,但没有解决方案.有人还建议使用警报使您的应用程序处于活动状态,但我不知道该怎么做.我想是这样的:

I have a Samsung Gear S and I'm bussy writing a web app. I would like to vibrate my app when I get a message from my server. I simply use navigator.vibrate(1000) and this works just fine. But when my app goes to the background the vibration doesn't work anymore. I've found this thread (https://developer.tizen.org/ko/forums/web-application-development/vibration-background?langswitch=ko) in which they face the same problem but there is no solution. Someone also suggested to use alarms to make your app active but I don't know how to do that. I suppose it is something like this:

var alarm = new tizen.AlarmRelative(1);
var service = navigator.vibrate(1000);
tizen.alarm.add(alarm, "org.tizen.browser", service);

这会失败,因为服务不正确.我怎样才能让它工作?

This fails because the service isn't correct. How can I get this to work?

推荐答案

如下方法:

您可以先打开屏幕灯然后振动.

You can turn on the screen light first then vibrate.

tizen.power.turnScreenOn();
navigator.vibrate(1000);

还不能正常工作.我不得不为振动添加延迟:

doesn't work quite yet. I had to add a delay for the vibration:

tizen.power.turnScreenOn();
setTimeout(function (){
    navigator.vibrate(1000);
}, 500);

这篇关于Tizen 应用程序振动背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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