我知道有一些技术可以查看 IOS 和 Android 应用程序是否再次打开(因此,如果用户最小化应用程序然后将其重新打开到相同状态),但我不确定如何在 Cordova 中执行此操作。有人成功过吗?
关于如何解决这个问题,我唯一的想法是要么每隔 x 秒检查一次我关心的数据,看看背景是否有变化,但这对移动数据来说似乎是不好的做法,尽管它们应该很小。
另一个想法是尝试编写一个可以使用原生技术的新插件,但还没有达到看起来很适合的程度。
希望有人有更好的主意,或者至少可以告诉我其中一个想法并不完全疯狂。
最佳答案
看着:
http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#resume
我明白了:
document.addEventListener("resume", yourCallbackFunction, false);
上面写着:
The resume event fires when the native platform pulls the application out from the background.
Applications typically should use document.addEventListener to attach an event listener once the deviceready event fires.
关于android - 如何确定是否已为 Cordova Apps 重新打开应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28434903/