English 中文(简体)
清理资源的应用程序终止事件
原标题:App termination event for cleaning up resources

交易内容如下:

我正在用Appcelerator Titanium构建一个移动应用程序。它将被部署到iOS和Android设备上。

我用钛。数据库模块,用于缓存应用程序显示的传入数据。当用户按下主页按钮/关闭应用程序时,我想关闭()数据库(并可能执行其他一些操作)。在后台,应用程序可以在没有警告的情况下被杀死(手动或由系统),所以我想在预料到这一事件时进行一些清理。

我看到API文档中提到的暂停、恢复和恢复事件,但它们只是iOS。

那么……我如何在Android上处理业务

最佳回答

您可以在Android中为当前活动添加一个事件监听器:

Ti.Android.currentActivity.addEventListener( pause , callback);

Ti.Android.currentActivity.addEventListener( resume , callback);

也许你在问如何在iOS上做到这一点?我会尝试用窗口监听器来聚焦和模糊。

问题回答

暂无回答




相关问题
Mysql trigger/events vs Cronjob

I have an auction website which let my users place an unlimited amount of autobiddings. To monitor these autobiddings something has to check the database every second. My question is if it is ...

Can an event be used as an event listener?

I m trying to expose some events from a private object which is contained inside the object I am creating and it looks like the compiler is happy with this: private WindowUpdateServer ...

鸡奸

由于将javascript DOM方法放在第html页底部(在<有人>之后)远比利用“j Query”准备活动要快得多,因此我们不得不这样做:

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

jQuery bind on ajax load() event

I have a page which displays multiple blocks with results details. Inside each block I have some <a> tags with thickbox jQuery plugin attached: class="thickbox" Here is an example of one kind ...

HTML text input event

I have a form, and want to disable/enable its submit button depending on whether the form s input text fields are empty or have had text entered into them. I think this means having an event handler ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...