7 Replies Latest reply on Aug 7, 2015 1:18 PM by SourceSkyBoxer

    Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!

    SourceSkyBoxer Level 1

      Hello dear people,

       

      welcome back! Did you know about old code for Flex 3.6x and Adobe Air 2.5x

      Look like this:

       

      package
      {
        import mx.core.Application;
        import mx.core.WindowedApplication;
        import adobe.utils.ProductManager;
           public class reboot
      
           {
      
             public function reboot():void
             {
               var app:WindowedApplication =
                   WindowedApplication(Application.application);
               
               var mgr:ProductManager = new ProductManager("airappinstaller");
          
               mgr.launch("-launch " + app.nativeApplication.applicationID + " " + app.nativeApplication.publisherID);
          
               app.close();
             }
           }
      
      }
      

       

      I have been tried for fixed problem for Flex 4.6 SDK and Adobe Air 3.1 Fix

       

      I have been replaced "Application" into "FlexGlobals" and changed all import-libraries for Flex 4.6 SDK Support.

      Example this:

       

      /**
       * 
       * Reboot of Air App
       * 
       */
      package
      {
                import adobe.utils.ProductManager;
      
                import flash.desktop.NativeApplication;
      
                import mx.core.FlexGlobals;
                import spark.components.WindowedApplication;
      
           public class reboot
           {
                public function Reboot():void
                {
                          var app:WindowedApplication = WindowedApplication(FlexGlobals.topLevelApplication);
      
                          var mgr:ProductManager = new ProductManager("airappinstaller");
                          mgr.launch("-launch "+app.nativeApplication.applicationID+" "+app.nativeApplication.publisherID);
                          app.close();
                }
           }
      }
      

       

      I add line for template-app.xml:

       

      <allowBrowserInvocation>true</allowBrowserInvocation>
      

       

      I have been tested with Application Air on Flex 4.6 SDK and Air 3.1 SDK. Yeah it works complety.

       

      And can you visit to my blog of byethost http://snakemedia.byethost7.com/blog/?p=15

       

      Thanks for help and support!

      Happy coding and best regards, Jens E.

        • 1. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
          SourceSkyBoxer Level 1

          Hello dear Coders, can you share my result for Flex 4.6 and Air 3.1

          I hope you because you can work your restarting air applications.

           

          I am sorry because i have been copied completed code but code tags are crazy. I have been edited always. Can you like my example for your nice wqay with Adobe Air Thanks and you are welcome

           

          Have fun! Best regards, Jens

          • 2. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
            Mitesh Sharma

            White publishing my build, it says:

            "Browser invocation is not supported for this target"

             

            NOTE: I am using air captiveRuntime to build my project instead of regular *.air.

             

            And airappinstaller" is a keyword ? or i can use any namespace ?

             

            regards,

            Mitesh

            • 3. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
              SourceSkyBoxer Level 1

              I am sorry for late

              This is not namespace- i think sure that

               

              "airappinstaller" = default Adobe Air

               

              "airappinstaller-captive" = Adobe Air Captive. I think sure. Thanks!

              • 4. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
                ketan156

                Hello SourceSkyBoxer,

                 

                I Have use that code in my AIR application to restart my application. But, i got some weird issue.

                I write that code on refresh button. So, When i restart my AIR application on refresh button click then application restart But, Skin and Image which i embed are not working after restart application.

                 

                I don't know why this thing happen.

                 

                Is there any solution for that?

                 

                Thanks.

                • 5. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
                  SourceSkyBoxer Level 1

                  Hi my dear sorry for late.. because i am trying with solution. If your embeded images from AS3 Project or Flex Project and they won't work. We need create frist swc ( Library ) like example: [Embed(source="image.png")] public static var myImage:Class; And add library into your project than bitmap or source of image component var img:Image = new Image(); img.source = MyLibraryFromImage.myImage; Don't worry if output sees warnning but it is okay. And restart with adobe air than it works..... :)

                  Hello @Mitesh Sharma sorry for mistake. For Adobe Air Captive won't work Thanks i am sorry

                  New improvement with NativeProcress works fine and if you don't worry if your name of application to change like example: "Airname.exe" to "xyz.exe" than restart like File.applicationDirectory.name+".exe" for Windows File.applicationDirectory.name+".app" for Mac OS X

                   

                  var appFile:String  = File.applicationDirectory.name+".exe";
                    var appNSPI:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                    appNSPI.executable = new File(appFile);
                    var appNP:NativeProcess = new NativeProcess();
                    appNP.start(appNSPI);
                  
                    this.close();
                  
                  

                   

                  Or method with airappinstaller:

                  var app:WindowedApplication = WindowedApplication(FlexGlobals.topLevelApplication);
                  
                    var mgr:ProductManager = new ProductManager("airappinstaller");
                    mgr.launch("-launch "+app.nativeApplication.applicationID+" "+app.nativeApplication.publisherID);
                    app.close();
                  
                  

                  restarted applications

                   

                  For ANe functions like OS to reboot and to turn of and more

                  I create soon for Path to C:\Windows\System32

                  example:

                  var shutdownFile:String = FileUtils.system32Directory.resolvePath("shutdown.exe").nativePath;
                  
                  var sdNPSI:NativeProcressStartupInfo = new NativeProcressStartupInfo();
                  sdNPSI.executable = new File(shutdownFile);
                  ...
                  ...
                  
                  
                  
                  • 6. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
                    eerku Level 1

                    i get the

                    TypeError: Error #1009: Cannot access a property or method of a null object reference.

                      at test_fla::MainTimeline/frame1()[test_fla.MainTimeline::frame1:14]

                     

                    message for mgr.launch line....

                     

                    my code:

                     

                     

                    import adobe.utils.ProductManager;

                    import flash.desktop.NativeApplication;

                    import spark.components.WindowedApplication;

                    import spark.components.Application;

                    import mx.core.FlexGlobals;

                    stop();

                     

                    var app:WindowedApplication = WindowedApplication(FlexGlobals.topLevelApplication); 

                    var mgr:ProductManager = new ProductManager("airappinstaller"); 

                    mgr.launch("-launch "+app.nativeApplication.applicationID+" "+app.nativeApplication.publisherID); 

                    app.close();

                     

                    please send a sample file... i dont sure our ProductManager class is ok....

                    • 7. Re: Updated Reboot / Restart of Application Air!!!! For Flex 4.6 SDK is important!!!
                      SourceSkyBoxer Level 1

                      Hey @eerku, Sorry for that with Flash Professional - I am not sure. I will try. I don't know you are right because mx and spark are only Flash Builder 4.6 / 4.7 Sorry i can not try that :( I will find solution. Thanks I am sorry for hard coding. I am sure if you want restart function from Air Native Extensions ( ANE ). But it is very simpler than old coding. Thanks!