> I am working on an app that I want to be able to open links from eg.
> an email app. I have an intent-filter that looks like this:
>
> <intent-filter>
>   <action android:name="android.intent.action.VIEW" />
>   <category android:name="android.intent.category.DEFAULT" />
>   <category android:name="android.intent.category.BROWSABLE" />
>   <data android:scheme="http" />
>   <data android:scheme="https" />
> </intent-filter>

That intent filter is evil.

> Now, if I click a link in an email, I get the dialog where I can
> choose whether to open the link with my app or with Browser. This is
> all well and good, but I also get this dialog whenever I click a link
> in the Browser app, or even enter a URL in the address field!

That's what you specified in the intent filter -- you claim to support
every HTTP(S) URL everywhere regardless of MIME type, host, or anything
else. That's why the intent filter is evil.

> Is there a way to circumvent this
> behavior in the Browser app, yet still present my app as an option
> when clicking links in email clients and the like?

Intent filters are agnostic to the sender of the Intent, so anything in
the system could send an Intent that your intent filter will match. Then,
if the sender uses Intent.createChooser(), like the Browser app does, you
will appear as a viable option.

Furthermore, you really need to more tightly constrain that intent filter,
so it is only going to be used for MIME types you actually will support,
or only from certain sites, or something. Look at the <data> element in
the SDK documentation:

http://developer.android.com/intl/fr/guide/topics/manifest/data-element.html

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to