如何区分通话后重新启动的应用与跳板启动的应用?

时间:2012-07-03 08:39:49

标签: iphone objective-c ios cocoa-touch

我希望我的应用程序具有不同的功能,具体取决于它是否在后台仍处于活动状态时启动(即未完全退出),而不是在电话呼叫后重新启动时。可能的?

我在stackoverflow上发现的答案主要与电话通话后如何恢复有关。

编辑:我在2008年的苹果论坛上找到了这个问题的答案,其中涉及根据普通电话的持续时间进行扣减,看起来这仍然是最有效的选择吗?

1 个答案:

答案 0 :(得分:1)

在您的appdelegate中,有两种方法可以在您的应用运行中运行,例如拨打电话:

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

当您的应用再次变为活动状态时调用。

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

确定如果您的应用处于后台或在通话开始时未运行,则无法判断是否已拨打电话。