Can You Run the Same Adobe AIR App More Than Once?

If you’re developing with Adobe AIR and wondering about the possibility of running multiple instances of the same application, you’re not alone. Many developers face this dilemma, especially when trying to manage applications that display or process various data streams, like thumbnails from photo streams. In this blog post, we will explore this problem in detail and provide clarity on whether it’s feasible to run two instances of the same Adobe AIR application.

The Issue at Hand

Imagine you have created a widget that showcases thumbnails from a couple of photo streams. Your goal is to be able to view multiple streams simultaneously. However, you may have encountered the frustrating limitation of Adobe AIR that restricts the ability to run the same app multiple times.

The Limitation Explained

According to the Adobe documentation:

“Only one instance of an AIR application is started. When an already running application is invoked again, AIR dispatches a new invoke event to the running instance.”

This clearly indicates that Adobe AIR is designed to launch a single instance of any application, meaning that if you attempt to start the same application again, it will instead trigger an event for the existing instance.

Understanding the Invoke Event

So, what happens when you try to run the application again? The Adobe AIR framework sends an “invoke event” to the currently running application instance.

How to Handle Invoke Events

To make the most out of this limitation, you can program your AIR app to respond to these invoke events by implementing a logic that opens a new document window or a similar window for each new request. This means that while multiple independent instances aren’t possible, you can still manage and display additional content through the existing application’s interface.

Here’s how to go about it:

  1. Listen for the Invoke Event:

    • Set up an event listener in your AIR application to detect when an invoke event occurs.
  2. Open New Windows or Panels:

    • Upon receiving an invoke event, program the application to open a new document or window that can display the additional photo stream you want to showcase.
  3. Manage State Appropriately:

    • Ensure that your application can appropriately handle multiple windows by managing states or requires data efficiently across instances.

Example

Suppose you want to open a new window to display an additional photo stream when the widget is clicked again. You can incorporate the following generic approach in your application code:

app.addEventListener(Event.INVOKE, onInvoke);

function onInvoke(event) {
    // Create a new window or panel for the new stream
    var newStreamWindow = new StreamWindow();
    newStreamWindow.show(); // Show the new stream window
}

Conclusion

While you cannot run separate instances of an Adobe AIR application, there are workarounds that allow you to handle the situation effectively. By using the invoke event method, you can create a more flexible and responsive user experience.

Although these workarounds may not be as seamless as running independent instances, they allow you to manage multiple streams in a single application context. Keep an eye on the official Adobe documentation for any updates or changes regarding this limitation in the future.

If you’re interested in more detailed insights or specific implementation questions, feel free to reach out!