[英]Application close notification in iphone when press home button twice
In iphone it when we press home button, application goes into the background. 在iphone中,当我们按下主页按钮时,应用程序进入后台。 And then when we press home button twice we can see list of running applications.
然后当我们按两次主页按钮时,我们可以看到正在运行的应用程序列表。 And then when we press that icon for long time one red round button comes, through which we can delete the app.
然后,当我们长按该图标时,会出现一个红色圆形按钮,我们可以删除该应用程序。
I wanted to know is there any notification comes for this particular situation in iphone. 我想知道是否有任何关于iPhone的特殊情况的通知。
Actually i wanted to handle this situation in my code, when we are closing our application by pressing home button twice. 实际上我想在我的代码中处理这种情况,当我们通过按两次home键关闭我们的应用程序时。
Please tell me some solution and please let me know it there is any clarifications required regarding this question. 请告诉我一些解决方案,请告诉我有关此问题的任何说明。
Thanks 谢谢
According to this question , when a user kills an app, it's a SIGKILL (as opposed to when iOS kills the app, which calls applicationWillTerminate). 根据这个问题 ,当用户杀死应用程序时,它是一个SIGKILL(而不是当iOS杀死应用程序时,它调用applicationWillTerminate)。
You cannot execute code for when a user kills the app, only for some general application states, such as active, background, suspended, and inactive. 当用户杀死应用程序时,您无法执行代码,仅适用于某些常规应用程序状态,例如活动,后台,暂停和非活动状态。 Check out Apple's documentation on app states.
查看Apple关于应用状态的文档 。
You should not (and can not) handle this specifically, because when the user double presses the home key and kills your app, that is what the user intends to do - he wants to kill your app. 你不应该(也不能)专门处理这个问题,因为当用户双击主页键并杀死你的应用程序时,这就是用户打算做的事情 - 他想要杀死你的应用程序。
The most common reasons for doing this is because there is a problem with your app. 这样做的最常见原因是您的应用程序存在问题。 Another reason could be that the user tries to cheat your app somehow (for example in a game), so the strategy I would recommend for you is:
另一个原因可能是用户试图以某种方式欺骗你的应用程序(例如在游戏中),所以我建议的策略是:
When you double tap on the home button the list of apps shown is not al list of apps running. 双击主页按钮时,显示的应用程序列表不是正在运行的应用程序列表。 But a list of apps started.
但是开始了一系列应用程序。 Sorted by the app that was start last.
按最后开始的应用排序。 That the app is in this list does not mean that it is running.
该应用程序位于此列表中并不意味着它正在运行。
When you kill an app here your app does not receive any notification that it is about to be killed. 当你在这里杀死一个应用程序时,你的应用程序不会收到任何即将被杀死的通知。 Your apps is thus not closed but killed.
您的应用程序因此未关闭但已被终止。
iOS might kill your app when it background if the system needs to free memory. 如果系统需要释放内存,iOS可能会在后台处理您的应用程序。 Again your app will not be notified in any way.
同样,您的应用不会以任何方式得到通知。 ( but this time it will stay in de list that popsup when you double tap the home button )
( 但是这次当你双击主页按钮时它会保留在弹出窗口中 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.