1

When I have a file in an app on my iOS device, I am able to open this file in other apps (which are registered for this file type), with a small dialog (src): Open with. Is there an Android equivalent to this dialog?
And if there is, how can I access it with Cordova?

EDIT: To make things clear: I want that dialog to be passive. So other apps can open a file in my app!

Clawish
  • 2,814
  • 2
  • 20
  • 28
  • Set up an `intent-filter` in your manifest. http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension – laalto Jan 20 '15 at 09:10

2 Answers2

1

In your manifest,

    <intent-filter>
        <action android:name="android.intent.action.SENDTO"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:scheme="sms" />
        <data android:scheme="smsto" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="image/*"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
Mohammed Imran N
  • 1,248
  • 1
  • 11
  • 25
  • Thank you! So if I open a file from, say, the file browser, in my app, how can the app interact with the file? Is the file path being passed as an argument? Or is the file copied into the application cache? – Clawish Jan 20 '15 at 13:15
  • consider your app is a DOC-Viewer. If you open a DOC from web browser, its mime type will check for Intents. In that case your mimeType matches, it will show open with option with your app present. This is my understanding and it is workign for me. Mine is PDF-Viewer App. – Mohammed Imran N Jan 20 '15 at 13:43
0

When you call startActivty, make use of Chooser, which will display available activities which can open the file you have selected.

For more info, check this link.

http://developer.android.com/training/basics/intents/sending.html

and

https://github.com/tannerburson/cordova-intent-chooser-plugin

EDIT:

make the changes as follows in your project manifest file for the activity, which you want other applications able to open.

<activity 
android:name=".view.MainActivity" 
android:label="@string/app_name" 
android:exported="true" >
Vilas
  • 1,668
  • 1
  • 12
  • 11
  • Thanks for your suggestion. However, I don't want to open a file from my app in another app, but vice versa. Another app should be able to open a file in my app. – Clawish Jan 20 '15 at 09:01
  • In project manifest file make the activity exported. Like, ex... – Vilas Jan 20 '15 at 09:05