0

我正在为 firefox mobile (fennec) 构建一个插件。是否可以检测浏览器是否在后台运行或屏幕是否被锁定,以便我可以暂停在我的扩展程序中运行的某些任务?

4

2 回答 2

1

You can also listen for the "application-foreground" and "application-background" notifications. Firefox does this itself here:

http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#5445

于 2012-06-20T22:16:36.050 回答
0

我不认为你可以 - Fennec 本身似乎并不关心屏幕是打开还是关闭,至少我找不到任何代码检查它。通常我会推荐js-ctypes直接调用必要的操作系统功能,但它在 Android 上的使用非常有限。所以我想你能做的最好的事情是使用nsIIdleService来检测用户何时处于非活动状态。

于 2012-06-14T06:45:28.867 回答