Thursday, March 29, 2007

dealing with fscommand launch

If you've ever wanted to use Flash Lite to communicate with C++ then fscommand("Launch",application) is a very useful feature. Its purpose is to allow you to launch an application on the phone and pass in addional command line parameters if necessary. So you could for example launch the browser and pass in a web address. Thats a basic example and there are other ways of doing that with getURL(). The real value in the launch fscommand is that it allows you to launch your own C++ application in the background to support your Flash Lite application.

In a recent Flash Lite project where we needed to use fscommand("Launch",app)
we came up against a few issues when it came to s60 3rd edition phones. So heres a summary of things to consider when using fscommand("launch").

You will probably have to call fscommand("launch") from a button press as it needs to be a user initiated action.

For 3rd Edition phones, because of the way applications are accessed you do not give an actual path to the application. So if I wanted to open the browser I would just do the following:

fscommand("Launch", "browser.exe");

For 2nd Edition phones you have to give the full path to the executable file. So for example:

fscommand("launch", "z:\\system\\apps\\browser\\");

Passing in arguments works the same across s60 3rd and 2nd edtion devices by putting the arguments after the application. eg.

For 2nd edition: fscommand("launch", "z:\\system\\apps\\browser\\,");

For 3rd edition: fscommand("launch", "browser.exe,");

However we were unable to read the arguments for our custom application. So it maybe that because of the security of the 3rd edition only the native applications such as browser can accept incoming arguments?

When it comes 2 way communication between Flash Lite and other applications the more effective way to do this is by running a local server on the device and then using loadVariables or even XMLsocket to talk to the native app. Although theres no point having a local server listen out for FL calls if FL isn't even running. So fscommand is again crucial here as a the starting point of communication.

Labels: , ,