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

前端之家收集整理的这篇文章主要介绍了android – 将参数从java活动传递到Adobe AIR应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们如何在启动另一个AIR类型的应用程序时从 Java Activity传递参数?

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

解决方法

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

By using this feature an application can be made invokable from browser or native android application. When the application is invoked from browser/android-app,an InvokeEvent is dispatched to the application.
For making an application invokable from browser,add this in your application descriptor (as child of application element):

<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>

Now to launch your application from browser,provide the url as: testapp://. An example is:

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

Clicking on this link will launch your application.

If you want to pass additional arguments to your application from browser,use something like this:

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

Once your application gets launched,fetch the arguments property of received InvokeEvent. This will contain the complete URI (testapp://arg1=value&secondArgument=someValue) and you can parse it to extract the arguments.

here起.

原文链接:https://www.f2er.com/android/316212.html

猜你在找的Android相关文章