Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters from a java activity to Adobe AIR app

How can we pass parameters from a Java Activity while launching another application of type AIR?

The way we do for java activities is using Intent's extra. What are the parameter passing mechanism when it's java Activity and AIR app on Android. Currently we are passing parameters by sharing a common place (sqlite db) and polling it every second. This is not a good design and I am sure there must be some good way to do this. Please enlighten me.

like image 840
ankitjaininfo Avatar asked Apr 08 '11 06:04

ankitjaininfo


3 Answers

In Adobe AIR 2.5 you can pass parameters to AIR app using custom URIs.

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.

From here.

like image 127
Michael Avatar answered Nov 04 '22 09:11

Michael


In addition to the above answer, to launch an adobe air application from an android app using Intent do this:

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);
like image 4
Jason Avatar answered Nov 04 '22 07:11

Jason


swf files are the output of the mxml , is the above method for passing the values from the android to the mxml or to the .swf . What changes we have to do from the .swf or .mxml side.I am compiling the mxml on FB(flash Builder) 4.5 and invoking it from the android eclipse. Rgds, saurabh

like image 1
Raulp Avatar answered Nov 04 '22 07:11

Raulp