簡體   English   中英

我該如何區分通話后重新啟動的應用程序和從跳板啟動的應用程序?

[英]How can I differentiate between an app relaunched after a phone call vs. an app launched from springboard?

我希望我的應用程序具有不同的功能,具體取決於它是在后台仍處於活動狀態(即未完全退出)時啟動還是在電話后重新啟動時啟動。 可能?

我在stackoverflow上找到的答案主要與根本沒有電話后如何恢復有關。

編輯:我在2008年蘋果論壇上找到了這個問題的答案,其中涉及根據您的平均通話時長進行扣除,看來這仍然是最有效的選擇嗎?

在您的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.
}

還有就是 一定 沒有辦法知道是否已經取得了手機,如果你的應用程序在后台或在呼叫開始沒有運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM