9/4/2010 10:38:56 PM
Title:
Restart app
How to restart an air app within the code?
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();
}
}
//
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?
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
9/6/2010 11:13:18 PM
Hello Flash_Guy
what is ProductManager class ?? library from Adobe or custom class ??
Regards,
Veerat
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
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
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?
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.