1 Reply Latest reply on Jan 26, 2009 10:32 AM by PeteApps

    Bringing AIR app to front

    Michl Schmid

      I'm looking for a solution to bring my "Flex coded" AIR app automatically to front when a certain event occurs.
      In my case this is a LocalConnection event that I'm listening to. I read through the LiveDocs
      and came to the NativeApplication class an its "activate()" method but I don't know how to
      glue things together that it works as expected...
      Hope someone can help!


        • 1. Re: Bringing AIR app to front

          I did the same thing with localconnection. I have an 'activate' method which I invoke through the localconnection. My class constructor get the NativeApplication object and stores it in nativeApp. In the 'activate' method, I just do

          nativeApp.activate ;

          This seems to work. An issue that you may run into is that there may not be an active window. I have code for minimize, restore, maximize, etc. Here is a snippet to get the active window.

          var nw:NativeWindow;
          nw = nativeApp.activeWindow;
          if ( nw == null ) {
          if ( nativeApp.openedWindows.length > 0 ) {
          nw = nativeApp.openedWindows[0] ;
          nativeApp.activate( nw );

          Complete the snippet with your 'else' and 'catch' logic. This seems to work fine for me.