I want to see what happens to my application if it is interrupted by a phone call or text message. Is there a way I can test this on the iPhone simulator?
It may not help in your situation (since it doesn't work in the simulator), but activating Siri works in a similar way to a phone call, sending your application to the background and interrupting audio, so is easier to test than making a call. Siri is on iPhone 4S and above, iPod touch 5th gen, and iPad 3 and above. Just hold down the home button if you have Siri enabled.
To expand on Lewis Gordon's answer it also works for devices without Siri. If you have voice control enabled then holding the home button down will interrupt audio and resign active.
Hardware -> Toggle In-Call Status will let you test the in-call UI.
I don't know of a way to test interruptions in the simulator, but as Lewis Gordon points out, you can bring up Siri on a device — even if there's no phone.
Related
I'm working on a location based app, which needs to send coordinates to server at a defined interval. It works properly on iPhone 4, even in background(see: iOS HTTP request while in background).
A friend of mine installed it on iPhone 3G with iOS 4.2.1 and after he put the app in background, it was killed by the OS. The app has 3 screens, first is a login screen. After he returns in foreground, the login screen appears again, instead the screen he has left open(which means the app was killed and restarted upon re-launch). on iPhone 4 work as expected.
Why on iPhone 3G the app is not run in background even it is declared as location app("required background modes" is set on "app registers for location updates")?
Because on iPhone 3G, multitasking is not officially available.
(you can jailbreak the iPhone, do some plist hackery and make your iPhone 3G have multitasking, but I suppose you don't consider jailbreaking at all even if you know about it.)
I locked the iPhone by calling the method GSEventLockDevice()from GraphicsServices.framework. It's working fine on the iPhone , but after locking the phone the backlight doesn't turn off. It remains lit and it shows the unlock screen.
How can I make the screen turn off immediately after locking?
Why are you doing this. Apple never accept this kind of private framework tasks. It must be jailbreak app. GraphicsServices.framework not deals with backlight and screen ON and OFF state. it just deals with GSEvents and other graphical things. I think you can't do that .
If you are developing for a jailbroken phone you could use GSEventSetBacklightLevel(0); to dim the brightness level.
I have GuitarToolkit on my iPhone4S (iOS 5.01 - NOT jailbroken) It has a metronome feature which continues playing in the background, and also adds a red banner overlay (see screenshots) which persists on the home/lock screen and also when other apps are running. The banner is animating (background colour pulses) and it is also 'active' in that pressing it will return you to the GuitarToolkit app.
I know about the background audio APIs for the sound, but how does it do this banner? My first thought was local notifications, but nothing appears in notification center, and GuitarToolkit is not listed under Notifications in Settings.
My iPhone is not jailbroken and GuitarToolkit is available in the App Store, so what APIs is it using to achieve this?
Having an active AVAudioQueue creates that banner.
The banner appears because it’s got an open audio recording session—you’ll notice that the system Voice Memos app does the same thing, as does Shazam for a moment before it enters the background and Skype when you’re on a call with the app in the background. I’m not sure of the specific API, but that’s generally what’s going on.
I would like to detect the status of the iPhone, such as if the screen is off (screen locked), or if the device has sound turned off.
Can an API do this, or is there any other way can do it?
Thanks vikingosegundo for helping me to edit the article,but the above is not what i want to know.
in my app, ijust want to check the device, i want to know if the iphone is sound off,and if the device is powered off(has no power). how can i know this ?
When the user locks the screen, applicationWillResignActive is called, and the app enters the "Inactive" state. Unless your app is running tasks that continue in that state (e.g. continuing to play audio) after about 20 seconds the phone will enter a sleep mode where your app is moved from inactive to its background state.
I work on jailbreak iphone, I want to know when user unlock the screen of iphone,is there any notification for unlock sreen by slide to unlock iphone? Thanks >>>>
From apple docs: use UIApplicationDidBecomeActiveNotification. This works only if your app is running so if you want to trigger some action on a background app running in a jailbroken device this is not the right solution.
UIApplicationDidBecomeActiveNotification
Posted when the application becomes active.
An application is active when it is receiving events. An active application can be said to have focus. It gains focus after being launched, loses focus when an overlay window pops up or when the device is locked, and gains focus when the device is unlocked.
Availability
Available in iOS 2.0 and later.
Declared In
UIApplication.h