views:

63

answers:

2

With the support of multitasking in iOS 4.0+, is there any way that I can have my application run in the background and detect the launching and exiting of other applications?

I know you can do this in Android, but I was wondering if this was now possible on the iPhone.

+3  A: 

iPhone's backgrounding feature puts the process to suspension which the user code can no longer control the app until it becomes active again. Therefore, even if another app is launched or exit, the backgrounded app cannot catch the notification.


(Anyway, to detect whether an app with ID com.yourcompany.foo becomes active or suspended, you could listen to the com.yourcompany.foo-activated and com.yourcompany.foo-suspended Darwin notifications.)

KennyTM
Darwin notifications?
Emil
@Emil: http://devworld.apple.com/library/mac/#documentation/Darwin/Conceptual/MacOSXNotifcationOv/DarwinNotificationConcepts/DarwinNotificationConcepts.html
KennyTM
@KennyTM So you'll need to use `CFNotification`s? http://developer.apple.com/library/ios/#documentation/CoreFoundation/Reference/CFNotificationCenterRef/Reference/reference.html
Emil
@Emil: Yes. Well, if you can control the backgrounded process.
KennyTM
A: 

Under the stock iOS, apps don't run in the background, only specific allowed tasks do (audio, VOIP, location logging, etc.)

hotpaw2