Skip to main content
Known Participant
March 10, 2013
Question

Air Android - Adapt the intent filter for receiving content from other apps

  • March 10, 2013
  • 3 replies
  • 13867 views

Hi,

I would like to use the Android intent filter for receiving content from other apps in an Air for Android app. What do I need to enter for .ui.MyActivity?

This is from the Android documentation:

When another application tries to share any of these things by constructing an intent and passing it to startActivity(), your application will be listed as an option in the intent chooser. If the user selects your application, the corresponding activity (.ui.MyActivity in the example above) will be started. It is then up to you to handle the content appropriately within your code and UI.

<activity android:name=".ui.MyActivity" >

<intent-filter>

        <action android:name="android.intent.action.SEND" />

        <category android:name="android.intent.category.DEFAULT" />

        <data android:mimeType="text/plain" />

    </intent-filter>

</activity>

I'm using Adobe Air 3.6 and Flash CS 6.

This topic has been closed for replies.

3 replies

Participant
July 27, 2015

It is possible to set this up for an Android "BroadcastReceiver"? Would love an example since I am not familiar with Android Development. Would like to avoid using any ANEs. Trying to receive with the Clover POS notifications: https://docs.clover.com/build/android-apps/app-notifications/. Thanks.

Participating Frequently
April 17, 2014

I've managed to get my application listed in the "share via" menu.

The problem is, as some people have stated in this thread, my application don't receive any data.

The InvokeEvent.arguments is empty on Android.

Does anyone found a solution?

blogtomAuthor
Known Participant
June 23, 2015

Did you found a solution yet?

gauravs2727
Adobe Employee
Adobe Employee
July 8, 2015

Hi,

Thanks for your replies. We have investigated this issue at our end. We were able to bring  AIR app to action from native android app.

We tried using different intent filters for investigation, but found some issue while using intent for SEND,SMS etc. While using intent.action.view and intent.category.BROWSABLE it is working fine.

Requesting you to please provide us a sample project at my official e_mail id gauravsh@adobe.com for further investigation and replicating this issue at our end.

We will make sure that project provided by you remains confidential with us.

Regards,

Adobe AIR Team

Inspiring
March 13, 2013

I don't use any and mine works.  See below.  Although I still have an issue in Gmail where you have to save before opening to get it into my app.  It is for text files.

<activity>

      <intent-filter>

      <data android:mimeType="text/plain" />

          <action android:name="android.intent.action.VIEW" />

          <category android:name="android.intent.category.DEFAULT" />

      </intent-filter>

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

          <action android:name="android.intent.action.GET_CONTENT"/>

          <action android:name="android.intent.action.EDIT" />

          <action android:name="android.intent.action.PICK" />

            <category android:name="android.intent.category.DEFAULT" />

          <category android:name="android.intent.category.BROWSABLE" />

          <data android:mimeType="text/*"/>

          <data android:scheme="http" android:host="*" android:pathPattern=".*\\.txt" />

          <data android:scheme="https" android:host="*" android:pathPattern=".*\\.txt" />

          <data android:scheme="content" android:host="*" android:mimeType="text/*"/>

          <data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.txt" />

       </intent-filter>

</activity>

In your AS code, you will need something like below...

import flash.events.InvokeEvent;

NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE,onInvoke);

var file_ani:File;

var fs_ani:FileStream;

function onInvoke(event:InvokeEvent):void

                              {

                                        trace("FileOpenExample.onInvoke(event)");

                                        if(event.arguments && event.arguments.length)

                                        {

                                                  var contentUri:String = event.arguments[0] as String;

                                                  trace("Content:", contentUri);

                                                  file_ani = new File(contentUri);

                                                  fs_ani = new FileStream();

                                                  fs_ani.openAsync(file_ani, FileMode.READ);

                                                  fs_ani.addEventListener(Event.COMPLETE, onFileComplete, false, 0, true);

                                        }

                              }

function onFileComplete(event:Event):void

                              {

 

                                        var fs:FileStream = event.target as FileStream;

                                        var fileContent:String = fs.readUTFBytes(fs.bytesAvailable);

                                        trace(fileContent);

                                        file_ani = null;

                                        fs_ani = null;

                              }

blogtomAuthor
Known Participant
March 14, 2013

Thanks for your answer.

Does it also work with the SEND intent?

<action android:name="android.intent.action.SEND" />

The SEND intent is the only one that gives me a empty event string.

Inspiring
March 14, 2013

Not sure.  What are you trying to accomplish?  The above code allows my app to receive content from other apps like DropBox etc but maybe the SEND is why I am not getting the Gmail to work properly unless the file is downloaded first.