How can my app keep getting a call to its "accelerometer:didAccelerate:" method of UIAccelerometerDelegate IF another app interrupts my app, such as the iPhone user receiving a phone call?
My app measures motion, but stops if suspended by the user, or if interrupted by another app.
I know this has been difficult in the past, but maybe there is something new in iOS.
Thanks!
You can't, apple standards are to block the app when a proccess pops in, It freezes the app at the moment it was interrupted. If finishes the last proccess it started in the background then it freezes the app. If you find a way around it i'd love to know it. Here is something that might help you to find the solution stackoverflow post similar to your question
Related
My app has to run for a long time (also) in the background, due to Location Services.
When a certain condition is met the app has to move to the foreground.
I was able to run my app in the background and bring it to the front manually.
Reading up on this issue I got confused on how to move my app to the foreground by code.
It has to be in an if statement but what to do from here?
No do not think this is possible. You will be able to spawn a UILocalNotification to show application state to the user, but it is my understanding that iOS prevents you from making your app take focus.
you can't do that without user interaction. You can present a UILocalNotification
-- you can't even be sure iOS leaves it running though!
on a jailbroken phone I guess it is possible
This is clearly not possible, as it would be a mess if any app could just take over control at any point in time. As mentioned, you have to post a notification, and then it is up to the user if he or she wants to launch the app. If you notification states a good reason why they should launch your app, they might very well do it :-) And remember, don't mix up the user's needs with your/your app's needs.
My specific requirement is an app that is in the background, being notified that the display is about to go to sleep or that the device has or is about to reach it's idle timeout - and then waking up and executing some (brief) piece of code.
I have found reference to notifications that an app is being put in the background or suspended here:
http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
And there seems to be a way of detecting on OSX:
http://developer.apple.com/library/mac/#qa/qa1340/_index.html
So, can a background iOS app receive notification that the display is going to sleep and execute just before it does?
No, thats not possible on iOS. I suggest you file a bug report at bugreport.apple.com and explain to them why you need such a feature, although this isn't a guarantee that such a thing will come. But if more people request this feature, the likelier it gets implemented.
I wrote my first iPhone App, and managed to get it into the App store. I later discovered a bug that happens on a real device but not on my emulator. I have committed a fix (changed plist to prevent app running in background), but I don't really understand why it happened.
My App allows users to record a sound-byte, however while they are recording they can use the iPhone home button to move the app to the background, and then it can keep recording forever if they don't restart the phone or the app does not crash.
My impression from everything I have read, is that this should not happen as you have to ask for background audio specifically if you want to do this, but now it appears to me that you have to ask specifically to disable it.
Could anyone explain this to me?
The iOS App lifecycle is described in Apple's iOS App Programming Guide.
The App is given the opportunity to save data and otherwise stop things that don't need to be running, before being suspended. You can request extra time doing this by using beginBackgroundTaskWithExpirationHandler:.
If you want your app to stop doing its "normal thing" when it is put into the background then you need to detect the App state transition and stop it yourself.
I want to develop an app which records the call-duration etc.. when a call is finished. So is it possible to start my app when the user finishes his call.
App is currently not running and then
User Finishes his Call ---> My app should open up the moment he finishes his call giving me the details about call duration etc.. and then i ask for some comments on that page and exit the app.
I already made such an app in Android,Blackberry.
P.S: Even if it works on a jailbroken iPhone it is good enough for me.
There's no way to do this on a regular iPhone. Apple's APIs don't allow you to interfere with phone calls at all.
Not sure about jailbroken phones though. In theory, you can do anything, it just depends on how much time you're willing to spend on it. Good luck.
how to regognize that user call somebody from code?(means i have an app and want to do sth when user call somebody)
You can't do that I'm afraid, firstly your app won't be running when they are calling someone and secondly you can't access the phone functions from the SDK. Might be possible with a background process on a jail broken phone.
This is not possible, not through code nor through notifications. You can't do anything to stop this, when a phonecall comes in, your application gets suspended, like as if you'd press home in iOS 4 and it will multitask if it has been programed to do so. Have a look at the UIApplication implementations for multitasking and do your work there.