Reputation: 1463
Is it possible to identify whether the user is on a phone call while using an app.
Here is the scenario:
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.
Upvotes: 4
Views: 376
Reputation: 5298
To elaborate on what Ben said, you'll want to subtract [UIApplication sharedApplication].statusBarFrame from the height you set your View to.
Upvotes: 1
Reputation: 69412
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.
Upvotes: 1
Reputation: 85542
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
Upvotes: 1