Firefox OS App(计时器)后台执行 [英] Firefox OS App (timer) Background Execution

查看:98
本文介绍了Firefox OS App(计时器)后台执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Firefox OS开发一个Pomodoro Timer应用程序,但在执行过程中遇到了问题: 一旦计时器运行,每当手机进入低功耗模式时,执行都会暂停(在我的场景中,这很典型,因为计时器运行25分钟),并且仅在屏幕再次打开.

I'm developing a Pomodoro Timer app for Firefox OS and I'm having a problem with the execution of it: Once the timer is running the execution is suspended every time the phone goes in low power mode (which is quite typical in my scenario, for the timer runs for 25mins) and is resumed only when the screen is turned on again.

我搜索了一种防止这种情况的方法,根据Mozilla文档,有两个API(空闲),可以:

I searched for a way to prevent this, and according to Mozilla docs there are two APIs (Power Management and Idle) by which you could either:

  • 防止屏幕关闭
  • 当应用进入低功耗模式时收到通知

不幸的是,这些API仅适用于认证的应用(手机随附的产品),这基本上意味着如果您要发布应用,则无法使用它们.

Unfortunately these APIs are available only for certified apps (the ones shipped with the phone), which basically means you can't use them if you want to publish your app.

你们中有人有同样的问题或对如何解决这个问题有暗示吗?

Is any of you having the same problem or have a hint on how to solve this?

推荐答案

特权应用可以使用navigator.requestWakeLock.

Privileged apps can use navigator.requestWakeLock.

navigator.requestWakeLock("cpu");

即使屏幕关闭,应用也永远不会挂起.

App will never suspend even if the screen is turned off.

背景服务API 更好,但尚未实现.

这篇关于Firefox OS App(计时器)后台执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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