0

I have seen several ways to "make sure that my app is shown again after a phone call which my app has initiated has ended" however that isn't what I want -> what I am looking for is a way to, say my app is currently running in the background doing network communications and someone calls me, I would like my app to either be able to "detect when the phone call has ended and resume my network communications" and/or "launch/resume my app back into the foreground when the phone call has ended". Is there any way to accomplish something like this and how?

4

2 回答 2

3

这在 iOS 中不受支持。

来自文档:http: //developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Reference/CTCallCenter/Reference/Reference.html#//apple_ref/doc/uid/TP40009604

如果您的应用程序在调用事件发生时处于活动状态,则系统会立即将该事件分派给您的处理程序。但是,调用事件也可能在您的应用程序暂停时发生。当它被挂起时,您的应用程序不会收到呼叫事件。当您的应用程序恢复活动状态时,它会为每个更改状态的调用接收一个调用事件 - 无论您的应用程序暂停时调用经历了多少状态更改。当您的应用程序返回活动状态时,发送到您的处理程序的单个调用事件描述了当时调用的状态。

您可以做的最好的事情是在您的应用程序打开时检测电话。

于 2013-05-11T00:59:11.153 回答
1

applicationWillResignActive当应用程序即将从活动状态变为非活动状态时调用。所以如果你接到一个电话,这个方法会在你的应用程序被后台调用之前被调用。

  • 使用此方法暂停任何正在进行的任务并保存您需要的任何设置。

applicationDidBecomeActive当您的应用再次激活时调用。

  • 使用此方法可以恢复任何暂停的任务。示例将恢复您的网络通信
于 2013-05-11T00:10:32.320 回答