views:

158

answers:

3

There are certain portions of my app that would be better to highlight to the user if they're on the phone.

Is there a call to check to see if we're on the phone? Unfortunately, "call" is a horrible word to check for in API documents for obvious reasons.

A: 

When the iPhone receives a call, the application exits. You can register a callback to handle this event gracefully, see:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplicationDelegate%5FProtocol/Reference/Reference.html#//apple%5Fref/occ/intfm/UIApplicationDelegate/applicationWillTerminate:

After the call has finished, your application will re-launch.

Applications that appear to preserve your state during a call are just written well :)


Arggh! I just read your actual question.

I cannot find, nor do I know of any APIs to access the phone application. My only advice would be that Phone is an application like any other - and it can publish information via the http tunnel all applications provide.

I wonder if you could just have an "I'm on the phone" button the user could press to achieve the same results?

Josh
+2  A: 

The application does not exit when a call comes in, it transitions to an inactive state. The following method should be called on the UIApplicationDelegate:

- (void)applicationWillResignActive:(UIApplication *)application

This method is also called in other cases, such as when the iPhone is locked, and you have no way of determining if it was an incoming phone call that caused it.

Stephen Petschulat
+3  A: 

Take a look at the difference in size between [[UIScreen mainScreen] bounds] and [[UIScreen mainScreen] applicationFrame]. If the diff is 20 pixels and you aren't hiding the status bar, then the users probably isn't on a call. If the difference is 40 pixels, your users is probably on a call, since the glowing green status bar that appears during calls is about twice as big as the normal status bar.

I haven't done this before, so YMMV. Good luck and let me know if it works!

kubi
I've thought this is the answer, but tethering does the same thing... :O(