Just to wrap up this thread for posterity so anyone in the future who
trips across it in a search will actually find something final and
applicable, here's how I got it working (Mark's reply wasn't quite the
ticket apparently).
First, Mark pointed out that the desired behavior is in fact
demonstrated in the NotePad example, a sibling of the API Demos
example. Thank you Mark! However, at least with respect to Linda
File Manager, the solution doesn't have anything to do with
android.intent.category.ALTERNATIVE or
android.intent.category.SELECTED_ALTERNATIVE, and as described below,
I'm unsure of the relevance of the mime type entry.
The relevant code from NotePad's manifest is the following activity
entry:
<activity android:name="NotesList" android:label="@string/
title_notes_list">
<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.EDIT" />
<action android:name="android.intent.action.PICK" />
<category
android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/
vnd.google.note" />
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.GET_CONTENT" />
<category
android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/
vnd.google.note" />
</intent-filter>
</activity>
In particular, the second intent-filter is the golden ticket, i.e.,
when a user taps a file in Linda File Manager and gets a list of apps,
is that second intent-filter which makes NotePad appear in the list of
options. Note, however, that I believe some of the other intent-
filters in NotePad's manifest add other activities of NotePad to that
same list as well, including perhaps the third intent-filter above,
I'm not sure yet. Incidentally, I discovered that w.r.t. Linda File
Manager, the exact action which is being triggered is VIEW (note that
it isn't ACTION_VIEW, it's VIEW, which makes sense given that it is
prefixed with "android.intent.action."). Also, as far as I can tell,
the right way to access the actual file once your app has been fired
up in onCreate() is to access the activity's intent's data string as a
file URI, thus:
public void onCreate(Bundle savedInstanceState) {
String uriStr = getIntent().getDataString();
}
Now you can parse the URI, get a path, and presumably open a file.
Maybe it isn't the right way to do it, but it's certainly *A* way to
do it.
Also, the value of mimeType, although presumably important as a
filter, doesn't play any role in this process as far as I can tell.
For example, NotePad uses "vnd.android.cursor.dir/vnd.google.note". I
tried "vnd.android.cursor.dir/vnd.myapp", "text/plain", and even "a/b"
just for kicks. It worked exactly the same way for all four mime
types in Linda File Manager (even "text/plain" worked on apk and mp3
files, which I hoped it would "filter" out). It is crucial to
actually *have* a mimetype entry in the intent-filter. If it is
removed, your app no longer appears as a launch option. It just
doesn't make any difference what the mime type actually is. Such is
the observed behavior based on my experiments.
The important thing is to have an intent filter with the VIEW action
and any mimeType (use something sensible though). That's it as far as
I can tell. That might be specific to Linda File Manager or it might
be generally applicable, I simply don't know yet, and trying to figure
t out by trial and error is not a very good way to nail down the
details, but I just can't figure out where this is documented.
Anyway, there it is, now anyone else can do it too, assuming they find
this thread. Go tell you friends.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---