I am making an application that can upload one or more files or folders. The intent filter is defined as follows:
<activity android:name=".UploadActivity" android:launchMode="singleTop" android:theme="@style/Theme.Sherlock"> <intent-filter android:label="@string/upload_intent"> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:mimeType="application/*" /> <data android:mimeType="audio/*" /> <data android:mimeType="image/*" /> <data android:mimeType="media/*" /> <data android:mimeType="multipart/*" /> <data android:mimeType="text/*" /> <data android:mimeType="video/*" /> </intent-filter> <intent-filter android:label="@string/upload_intent"> <action android:name="android.intent.action.SEND_MULTIPLE" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:mimeType="*/*" /> </intent-filter> </activity>
This works great with Blackmoon File Explorer and Android 4.0.3 Gallery. My application is displayed in the Share menu. However, it also appears in the browser when you click the URL for a long time and select Share Page.
When I send a text file to my application, I get the following:
getIntent().getAction() returns Intent.ACTION_SEND getIntent().getType() returns "text/plain" getIntent().getScheme() returns null getIntent().getExtras().getString(Intent.EXTRA_STREAM) returns the filename
However, sending the URL from the browser returns the same minus Intent.EXTRA_STREAM. I can easily find it in the code and say "hey, I canβt load the text!" but I would prefer to change the intent filter so that it only works when EXTRA_STREAM is present. Can this be done?
(I tried using the android: scheme, but this will not distinguish between the file and the common text string, as both of them are null ...)
source share