Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an intent-filter than would only show an app in the share menu when sharing a url?

I have looked at the intent-filter documentation and I can't figure out this specific intent-filter.

I'm looking to use ACTION_SEND because I only want the app to show up in "Share" menus in other apps. I only want to show up in the share menu if the text of the intent is a url. For example, what is shared from the Android Browser's share menu. I don't want the app to appear in the share menu if it's just text and not a url.

What I have so far is:

<intent-filter android:label="Label">
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="text/*" />
</intent-filter>    

However, this will receive any text, not just urls.

Thanks

like image 673
cottonBallPaws Avatar asked Nov 15 '22 06:11

cottonBallPaws


1 Answers

You can create IntentFilter objects programmatically, and they can filter on URI schema among other things... much more control.

I thought subclassing IntentFilter would give you event more, but they made all the variations on "match" final so you can't override them in a subclass. Bah!

Eurika!

You can specify a data "scheme" instead of a mimetype. Just ask for "http" and "https" (in separate intent filters?).

<intent-filter>
  ...
  <data android:scheme="http"/>
</intent-filter>
like image 99
Mark Storer Avatar answered Dec 17 '22 11:12

Mark Storer