通过URL打开Native AIR应用程序?

时间:2012-01-21 20:17:50

标签: air

我希望人们能够通过URL启动Native AIR应用程序。我的AIR应用程序会在其上读取一些参数并打开到正确的状态。

因此,用例将是某人浏览我们的网站,然后点击链接,它会打开本机桌面应用程序以找到与其链接相关联的正确内容。

我知道iTunes会这样做,其他应用也支持它。

我知道AIR(非本机)安装程序也支持此功能。

我不知道是否可以使用本机AIR应用程序(.exe或.dmg安装)执行此操作。

编辑:这适用于桌面。

3 个答案:

答案 0 :(得分:5)

对于iPhone,你应该使用Url方案 http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

对于Android,您应该像这样编辑AndroidManifest.xml

   <activity android:name=".MyUriActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="myapp" android:host="path" />
    </intent-filter>
   </activity>

您可以在此处找到更多答案 How to implement my very own URI scheme on Android

答案 1 :(得分:4)

好的,这就是桌面应用程序的用法。

- 首先在应用程序描述符文件中将allowBrowserInvocation设置为true:     真正 (http://livedocs.adobe.com/flex/3/html/help.html?content=File_formats_1.html#1043413)

- 应用程序必须在开始时监听BrowserInvokeEvent 然后你可以像这样使用传递给应用程序的参数:

public function onInvokeEvent(invocation:InvokeEvent):void 
{
    arguments = invocation.arguments;
    currentDir = invocation.currentDirectory;
}

- 您只能从SWF启动AIR APP。浏览器中的SWF文件可以通过调用从http://airdownload.adobe.com/air/browserapi/air.swf加载的air.swf文件中的launchApplication()方法来启动AIR应用程序。 加载air.swf文件后,SWF文件可以调用air.swf文件的launchApplication()方法,如下面的代码所示:

var appID:String = "com.example.air.myTestApplication";
var pubID:String = "02D88EEED35F84C264A183921344EEA353A629FD.1";
var arguments:Array = ["launchFromBrowser"]; // Optional
airSWF.launchApplication(appID, pubID, arguments);

了解更多信息 http://livedocs.adobe.com/flex/3/html/help.html?content=app_launch_1.html#1038008

希望它有所帮助。

答案 2 :(得分:0)

完成后注册BrowserInvokeEvent, NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE,onBrowserInvoke);

然后定义,

protected function onBrowserInvoke(event:BrowserInvokeEvent):void             {                 arguments = event.arguments;             }