0

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

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

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

4

1 回答 1

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.
}

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

于 2012-07-03T08:44:35.077 回答