Invoking an AIR app from another AIR app

December 22, 2008

Today I was just trying to see how to launch one AIR app from another… The idea struck me when I was reading –Installing and running an AIR applications from a web page documentation on livedocs and I thought it is worth posting here.

There is an air.swf file file at [http://airdownload.adobe.com/air/browserapi/air.swf]. One can invoke a launchApplication() method on the file to interact with the AIR runtime and launch installed AIR applications from a web page in a browser. I decided to use the same file to launch AIR apps from another AIR app. To get this working, the trick is very simple:

  1. Get the applicationID and the publisherID of the app intended to be invoked

    applicationID can be obtained, either from the author of the application or looking at the application.xml file funder the META-INF/AIR folder in the application install directory.

    publisherID can be obtained, either from the author of the application or in the publisherid file under the META-INF/AIR folder in the application install directory.

  2. First load the air.swf in an instance of the Loader class and set the LoaderContext as mentioned here under “Loading the air.swf file” heading.
  3. Do a check if the application is installed using the code under “Checking from a web page if an AIR application is installed” heading.
  4. Use the following code to launch the application

    var appID:String = enter applicationID here;
    var pubID:String = enter publisherID here;
    airSWF.launchApplication(appID, pubID);
  5. Done…

Note:

This would only work if the application.xml file of the application that you want to launch has the allowBrowserInvocation property set to true.

Here is an example of 2 apps, AIRAppLauncher and AIRAppLaunched. AIRAppLauncher can be used to launch AIRAppLaunched. You will have to sign the AIRAppLaunched, export as AIR, extract the publisherID, install it and use that in AIRAppLauncher for the whole workflow to work. You can download the archive here