将参数从java活动传递到Adobe AIR应用程序

时间:2011-04-08 06:02:57

标签: android air parameter-passing

我们如何在启动另一个AIR类型的应用程序时从Java Activity传递参数?

我们为java活动做的方式是使用Intent的额外功能。 Android上的java Activity和AIR app是什么参数传递机制。目前我们通过共享一个公共位置(sqlite db)并每秒轮询它来传递参数。这不是一个好的设计,我相信必须有一些好的方法来做到这一点。请赐教。

3 个答案:

答案 0 :(得分:9)

在Adobe AIR 2.5中,您可以使用自定义URI将参数传递给AIR应用程序。

  

通过使用此功能,可以从浏览器或本机Android应用程序调用应用程序。从browser / android-app调用应用程序时,会将InvokeEvent分派给应用程序。   要使应用程序可以从浏览器调用,请将其添加到应用程序描述符中(作为应用程序元素的子代):

<android>
    <manifestAdditions>
    <![CDATA[
        <manifest>
            <application>
                 <activity>
                     <intent-filter>
                         <action android:name="android.intent.action.MAIN"/>
                         <category android:name="android.intent.category.LAUNCHER"/>
                     </intent-filter>
                     <intent-filter>
                         <action android:name="android.intent.action.VIEW"/>
                         <category android:name="android.intent.category.BROWSABLE"/>
                         <category android:name="android.intent.category.DEFAULT"/>
                         <data android:scheme="testapp"/>
                     </intent-filter>
                 </activity>
             </application>
         </manifest>
     ]]>
     </manifestAdditions>
</android>
  

现在要从浏览器启动您的应用,请将网址提供为:testapp://。一个例子是:

<a href="testapp://">click here to launch air test app from browser</a>
  

点击此链接即可启动您的应用程序。

     

如果要从浏览器向应用程序传递其他参数,请使用以下内容:

<a href="testapp://arg1=value&secondArgument=someValue">click here to launch air test app from browser</a>
  

启动应用程序后,获取收到的InvokeEvent的arguments属性。这将包含完整的URI(testapp://arg1=value&secondArgument=someValue),您可以解析它以提取参数。

来自here

答案 1 :(得分:4)

除上述答案外,使用Intent从Android应用程序启动adobe air应用程序:

Intent i = Intent.parseUri("testapp://arguments-to-pass",Intent.URI_INTENT_SCHEME);
i.addCategory(Intent.CATEGORY_BROWSABLE);
i.setComponent(null);
i.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
startActivity(i);

答案 2 :(得分:1)

swf文件是mxml的输出,是上面的方法,用于将值从android传递到mxml或.swf。我们要从.swf或.mxml方面做些什么改变。我正在编译FB(flash Builder)4.5上的mxml并从android eclipse中调用它。 RGDS, SAURABH