如何检测什么触发了applicationWillResignActive?
我有一个视频聊天应用程序,我想在设备锁定时断开通话,但在收到短信、日历、电池电量低或任何其他类型的通知时保持连接。问题是,我一生都无法弄清楚如何确定导致调用我的应用程序委托的 applicationWillResignActive 选择器的原因。
我考虑过实现某种超时,如果在一定秒数内没有调用 applicationDidBecomeActive 我会断开连接,但这错误地假设用户将在该秒数内忽略或接受收到的通知。
谁能帮我找出一种方法来确定导致 applicationWillResignActive 选择器被调用的原因?
非常感谢, 石匠
I have a Video Chat application that I want to disconnect from a call when the device is locked, but stay connected when an SMS, calendar, low battery or any other type of notification is received. The problem is, I cannot figure out for the life of me how to determine what causes my app delegate's applicationWillResignActive selector to be called.
I have thought about implementing some kind of timeout where if applicationDidBecomeActive was not called within a certain number of seconds I would disconnect but that falsely assumes that a user will ignore or accept a received notification within that number of seconds.
Can anyone help me figure out a way to determine what caused the applicationWillResignActive selector to be called?
Many Thanks,
Mason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为简短的答案可能是,您无法真正确定具体是什么原因导致辞职电话,但是您只能根据它是否确实在后台进行计划。
查看此链接,其中详细介绍了多任务处理所需的步骤。
http://www.cocoanetics.com/ 2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/
祝你好运,你看起来是个很棒的人!
I think the short answer may be, that you can't really determine specifically what causes the resign call, however you can only plan according to if it actually goes in the background or not.
Check this link out where it details the steps multitasking takes.
http://www.cocoanetics.com/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/
Good luck, you seem like an awesome guy!
就我而言,我正在停止 NSNotification.Name.UIApplicationWillResignActive 上的视频捕获,
现在,我正在使用:
NSNotification.Name.UIApplicationDidEnterBackground
当消息到来或有人呼叫捕获设备时,它不会被触发。
In my case I was stopping the video capturing on NSNotification.Name.UIApplicationWillResignActive
Now, I'm using the:
NSNotification.Name.UIApplicationDidEnterBackground
It isn't triggered when a message comes, or in case someone is calling to the capturing device.