header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Mac
Points:0
Posts:0
Answered

9/4/2010 10:38:56 PM

Title: Restart app


How to restart an air app within the code?



1
Flash_Guy
Points: 830
Posts:0
Accepted Answer
9/4/2010 11:13:35 PM



you can use the following code to restart an adobe air application. Also make sure that you set the “allowBrowserInvocation” option to on in the AIR application descriptor template


package
{
  import mx.core.Application;
  import mx.core.WindowedApplication;
  import adobe.utils.ProductManager;

  public function restart():void
  {
    var app:WindowedApplication = WindowedApplication(Application.application);
   
    var mgr:ProductManager = new ProductManager("airappinstaller");
   
    mgr.launch("-launch " + app.nativeApplication.applicationID + " " + app.nativeApplication.publisherID);
   
    app.close();
  }
}
// 

2
Mac
Points: 0
Posts:0
9/4/2010 11:42:46 PM



what is the "airappinstaller" in the code?
when I ran it only the application is closed not restarting.
what may be the reason?

3
Flash_Guy
Points: 830
Posts:0
Accepted Answer
9/5/2010 12:00:18 AM



in the AIR application descriptor template have you set this
<allowBrowserInvocation>true</allowBrowserInvocation>

the string "airappinstaller" is standard string

4
Veer
Points: 480
Posts:0
9/6/2010 11:13:18 PM



Hello Flash_Guy

what is ProductManager class ?? library from Adobe or custom class ??

Regards,
Veerat

5
Flash_Guy
Points: 830
Posts:0
9/6/2010 11:31:00 PM



you can always look at import to see that

import adobe.utils.ProductManager;

its from adobe, for Adobe AIR applications

6
Luke McS
Points: 0
Posts:0
11/12/2010 8:27:02 AM



Hi guys, cheers for the code it worked a treat for me. I had to change it slightly for flash (as in not flex) and thought it maybe useful for some people. Heres what i did.

the code is basicly the same, only dif is you wont have the "mx.core.WindowedApplication" libray to import. so instead do this:

var mgr:ProductManager = new ProductManager("airappinstaller");
mgr.launch("-launch " + NativeApplication.nativeApplication.applicationID + " " + NativeApplication.nativeApplication.publisherID);
NativeApplication.nativeApplication.exit();

you will need to include:

import flash.desktop.NativeApplication;

in your imports.

Then look were your airfiles are being created and you will see a file called ["name of your air file"]-app.xml . open this and as mentiond before make sure that <allowBrowserInvocation>false</allowBrowserInvocation> is set to true:

<allowBrowserInvocation>true</allowBrowserInvocation>
cheers, hope its some help

7
Wemerson Guimararães
Points: 0
Posts:0
4/9/2011 8:38:38 PM



Hi... Great code...

If i'm need to restart my app and send any informations about my last instance... there are a way to restart and send parameters?

8
Friend
Points: 690
Posts:0
4/10/2011 5:21:34 AM



I don't think there is direct way to send parameters. But I see a workaround . You can write a text file and write parameters in that file. On restart of application read that file always for any parameters. After reading the parameters delete them. to avoid reading old parameters again and again.


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+6 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions