iphone applicationWillResignActive - get reason
I wonder, if there's a way to get reason of applicationWillResignActive being called?
I'm developing an audio app, and I want to continue recording sound when the screen is auto locked, but I want to stop recording开发者_如何学C when incoming call occurs. How can I do that?
You can simply use the AVAudioSessionDelegate protocol methods like: beginInterruption
and/or endInterruptionWithFlags:
to check if the recording is interrupted and than you can do whatever you need.
In this case this approach has an advantage over registering to telephony events, because it works all the time recording, and not only for the first 10 minutes.
You can refer to the Core Telephony Framework in your application. This framework gives you the possibility of listening to the events and state of the phone on your device.
Moreover, the CTCallCenter
class gives you the possibility of registering to telephony events to appropriately handle them through your application. This way you will be able to call a specific callback when an incoming call arrives, a call is started, terminated and so on. See the full list of cellular call states.
Hope this helps.
精彩评论