Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经使用 phonegap 为 android 构建了一个应用程序,我需要问一个问题,关于如何通过按下你的 android 设备的主页按钮来完成你离开它的应用程序。我尝试过使用 java 中的 finalize() 方法,但我不知道将它放在我的代码中的哪个位置。很抱歉这个非常笼统的问题。
谢谢
也许如果你把函数放在你的身体里:onunload="yourfunction()"。
当您退出应用程序时,操作系统会将您的应用程序置于“暂停”状态,然后再将其杀死。您可以为此设置一个侦听器: document.addEventListener("pause", yourfunction, false);
希望它对你有用。