简体   繁体   English

按两次主页按钮时,在iphone中应用关闭通知

[英]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: 另一个原因可能是用户试图以某种方式欺骗你的应用程序(例如在游戏中),所以我建议的策略是:

  1. Build your app well, so the user will not terminate it because of problems =) 很好地构建你的应用程序,因此用户不会因为问题而终止它=)
  2. Save your application data and application state in 保存您的应用程序数据和应用程序状态
    the "applicationWillEnterBackground" event. “applicationWillEnterBackground”事件。 This way you are 这样你就是
    guaranteed that the user will not loose any data if he/she closes the app (in a normal manner) 保证用户在关闭应用程序时不会丢失任何数据(以正常方式)
  3. If you think the user will try to "cheat" your app, save your application data in critical moments while the app is running. 如果您认为用户会尝试“欺骗”您的应用,请在应用运行时的关键时刻保存您的应用数据。 For example if you are making a game and the player fails a mission, save the app state immediately so that the player cannot cheat by killing the app. 例如,如果您正在制作游戏并且玩家未能执行任务,请立即保存应用程序状态,以便玩家无法通过杀死应用程序来作弊。

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.

相关问题 有没有一种方法可以模拟iPHone的“主页”按钮按下并通过javascript重新启动应用程序 - Is there a way to simulate iPHone “Home” button press and relaunch the application throught javascript iPhone iOS应用程序主页按钮按下/ applicationDidEnterBackground崩溃 - iphone ios application home button press/applicationDidEnterBackground crash 当我运行我的iPhone应用程序时,它只显示一个白色的窗口,但是当我按下主屏幕按钮时,它显示了输出问题。 - When i run my iPhone application it just show a white window, but when I press home button then it shows output what's wrong with it? 按下“主页”按钮后,iPhone关闭键盘 - iPhone Close Keyboard When After Hitting Home Button 长按iPhone应用程序中的主页按钮 - Long press home button in iPhone app 模拟 Home 键按下 - iPhone 测试 - Simulating a Home Button Press - iPhone Testing 在C#中按iPhone中的“主页”按钮,从子应用程序返回到父应用程序 - Go Back to Parent application from child application on press of Home button in iPhone in C# iPhone启动带有主页按钮的应用程序 - IPhone launch application with home button iOS:当iPhone处于睡眠模式或按主屏幕按钮时,执行NSURLConnection - iOS: Perform NSURLConnection when iphone is in sleep mode or when i press the home button 退出iPhone中的主页按钮时如何暂停应用程序 - How to pause the application when quit the home button in iphone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM