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.
Related
I have an application that gets hidden (but is still running in the background) when the screen saver starts on the 4th Generation Apple TV.
How can I bring the app to the foreground (hide screen saver) when an event (update to an endpoint which I am long polling) happens in my app which is running in the background?
I don't think there's any way to do this. When the screen saver is running, your app can still be the foreground app, but it will be in an inactive state. This is similar to what happens on iOS when the user locks the screen while using an app. Like the iOS lock screen, the user might be actively using the system when it's in this state. For example, you can use Siri without dismissing the screen saver.
friends I am new to iphone development, I have mostly worked with Android, now I have to develop a small clock for Iphone which should be shown on lock screen like following app
http://itunes.apple.com/us/app/weather-lock-screen-free/id433369569?mt=8
just a start idea how can i place an app at iphone lock screen since i have already created the (analog ) clock, thanks for your help
Faisal
This app doesn't actually set the background of the lock screen. It asks the user to save an image, then the user has to set the image as the background for the lock screen manually.
There is no API to do what you want.
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 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.
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