Difference between revisions of "SBApplication"

From iPhone Development Wiki
Jump to: navigation, search
(Get all active applications)
Line 19: Line 19:
 
Getting active applications traditionally need to be done via the static function at <tt>0xeadc</tt>, or evaluate through the result of {{ObjcCall|SBApplicationController|allApplications}} and check if the <tt>pid</tt> is valid. Fortunately, starting from 3.0, the SpringBoard class provides a method {{ObjcCall| SpringBoard|_accessibilityRunningApplications}} which directly calls <tt>0xeadc</tt>. Therefore, you can get the array of active applications from this.
 
Getting active applications traditionally need to be done via the static function at <tt>0xeadc</tt>, or evaluate through the result of {{ObjcCall|SBApplicationController|allApplications}} and check if the <tt>pid</tt> is valid. Fortunately, starting from 3.0, the SpringBoard class provides a method {{ObjcCall| SpringBoard|_accessibilityRunningApplications}} which directly calls <tt>0xeadc</tt>. Therefore, you can get the array of active applications from this.
  
Starting from 3.2 one can also use {{ObjcCall|SpringBoard|_accessibilityFrontMostApplication}} to get the front most application.
+
Starting from 3.2 one can also use {{ObjcCall|SpringBoard|_accessibilityFrontMostApplication}} to get the front most application. If you know the app you can check if [[app process] isFrontmost].
  
 
== Launching an SBApplication ==
 
== Launching an SBApplication ==

Revision as of 00:29, 10 December 2010

SBApplication is a class representing the application screen on the SpringBoard. SBApplication is a subclass of SBDisplay. See SBDisplay for more info.

Retrieving an instance of SBApplication

To retrieve a known instance, you must go through SBApplicationController. For example, if the display ID of the application is known, you can use:

SBApplication* app = [[SBApplicationController sharedInstance] applicationWithDisplayIdentifier:@"com.yourcompany.appname"];

Get all active applications

Signature -(NSArray*)_accessibilityRunningApplications;
Available in 3.0 –
Signature -(SBApplication*)_accessibilityFrontMostApplication;
Available in 3.2 –

Getting active applications traditionally need to be done via the static function at 0xeadc, or evaluate through the result of -[SBApplicationController allApplications] and check if the pid is valid. Fortunately, starting from 3.0, the SpringBoard class provides a method -[SpringBoard _accessibilityRunningApplications] which directly calls 0xeadc. Therefore, you can get the array of active applications from this.

Starting from 3.2 one can also use -[SpringBoard _accessibilityFrontMostApplication] to get the front most application. If you know the app you can check if [[app process] isFrontmost].

Launching an SBApplication

To launch an SBApplication you can use SBUIController:

[[SBUIController sharedInstance] activateApplicationAnimated:app];

Note 1. this method will not respect parental control. You can look up the list of restricted apps using -[SpringBoard parentalControlsDisabledApplications], however.

Note 2. this method will only work if on the home screen. It will not work when already in an application.

Application Info.plist

SpringBoard will recognize the following Info.plist keys:

Starting from 3.2 these documented keys are also recognized:

  • ProductType, UIDeviceFamily, DeviceFamily[4]
  • UIAppFonts
  • UIFileSharingEnabled
  • UISupportedInterfaceOrientations

References