Skip to main content
Participating Frequently
November 23, 2011
Question

How to send parameter from android to air ??

  • November 23, 2011
  • 4 replies
  • 3168 views

hi..

i try send parameter from android to air using intent..

[android .java] -----------------------

Intent intent = new Intent();

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

intent.setAction(Intent.ACTION_VIEW);

intent.addCategory(Intent.CATEGORY_BROWSABLE);

intent.addCategory(Intent.CATEGORY_DEFAULT);

intent.putExtra("myKey", "1234567890");

intent.setClassName("air.SharedIntentSample.debug", "air.SharedIntentSample.debug.AppEntry");

startActivity(intent);


[Air .xml] -----------------------

<application android:enabled="true">

          <activity android:excludeFromRecents="false">

                    <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="tel:" />

                    </intent-filter>

          </activity>

</application>

[Air invoke handler .as] -----------------------

protected function onInvokeEventHandler(event:InvokeEvent):void

{

          trace("[SharedIntentSample::onInvokeEventHandler(event)]" + arguments);

          trace("[SharedIntentSample::onInvokeEventHandler(event)]" + event.arguments);

          trace("[SharedIntentSample::onInvokeEventHandler(event)]" + event.reason);

          trace("[SharedIntentSample::onInvokeEventHandler(event)]" + event.arguments.length);

}

but, it's not work..

How to send parameter from android to air..??

This topic has been closed for replies.

4 replies

Participant
March 13, 2012

Hi, putExtra did not work either for me but I've found alternative with the next code:

Air App code is like yours (with invokeEvent) and you have to add this in your manifest:

     <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="my-scheme"/>

             </intent-filter>

     </activity>

In your Android App:

           Intent i = null

           try

           { 

                   i = Intent.parseUri("my-scheme://arg=value",Intent.URI_INTENT_SCHEME);

           }

           catch (URISyntaxException e) {

                    e.printStackTrace();

          }

          

           i.addCategory(Intent.CATEGORY_LAUNCHER);

           final ComponentName cn = new ComponentName("your.package.name", "your.package.name.AppEntry");

          i.setComponent(cn);

           i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

           startActivity(i);

Anyway, anybody knows how do it using putExtra?





El mensaje fue editado por: jose4mgg

Participant
March 7, 2012

Don't use Intent.

Intent is necessary to send Parameters between to distinct activities.

Adobe had a DispatchEvent system in his android framework.

Every classes extended FREContext is able to use the dispatchStatusEventAsync() method.

In your handler, you just need to listening for StatusEvent.

So in MyAndroidContext extends FREContext

int value = 255;

this.dispatchStatusEventAsync("parameterName", Integer.toString(value));

Handler.as

(myExtensionContext as ExtensionContext).addEventListener(StatusEvent.STATUS, onReceive);

private function onReceive(e:StatusEvent):void

{

     switch(e.code){

          case "parameterName":

               trace(e.level);     //should be 255

          break;

          default:

               /*     */

     }

}

Participant
December 3, 2011
cbigbAuthor
Participating Frequently
November 25, 2011

anybody help me??