如何确定是否已为 Cordova Apps 重新打开应用程序?
How to determine if app has been re-opened for Cordova Apps?
我知道有一些技术可以查看 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.
我知道有一些技术可以查看 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.