4

Is it possible to identify whether the user is on a phone call while using an app.

Here is the scenario:

  1. I get a call
  2. I accept the call
  3. Tap the home button
  4. Launch an app

At this point can I tell this app that a call is going on in background?

Getting to know the screen is not a full blown option. Because it makes life difficult when on internet tethering.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
AJ.
  • 1,443
  • 7
  • 19
  • 31

3 Answers3

1

You could check the height of the status bar. If it's more than 20px, you're either on a call, or tethering (which is not supported on AT&T, so it must be on a call if you're in the US).

[UIApplication sharedApplication].statusBarFrame
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
  • I would hope that nobody is assuming that because tethering is not supported on AT&T that it automatically means they're on a phone call. There's an awful lot of iPhones that are not US based... – Wally Lawless Dec 02 '09 at 14:22
  • I'd hope so too, plus I'm still holding out hope for AT&T tethering! – Ben Gottlieb Dec 02 '09 at 15:42
  • Whenever I use [UIApplication sharedApplication].statusBarFrame in a NSLog statement, it shows the frame to be "0". What's up? – Jonah Apr 19 '10 at 21:55
  • Are you wrapping the frame in NSStringFromCGRect(...)? – Ben Gottlieb Apr 19 '10 at 22:07
  • In this case, for example if user has an on going Skype call, how I could tell difference between an on going call and a Skype call. – user454083 Apr 20 '12 at 12:52
1

There isn't a public API for any phone state or functionality, so you'll have to rely on side-effects of being on a call.

You can either check the status bar like Ben Gottlieb suggested, or you can try to initialize an audio recording, if it fails with an error of already in use, you can be fairly certain the microphone is being used for a call.

Ben S
  • 68,394
  • 30
  • 171
  • 212
1

To elaborate on what Ben said, you'll want to subtract [UIApplication sharedApplication].statusBarFrame from the height you set your View to.

pixel
  • 5,298
  • 8
  • 35
  • 32