2

I am reading the intent filter of the android, and having a few question need to ask.

  1. Do they match the filter within the same application or all of the applications?

  2. The scheme within the data tag, I have looked on the documentation on the android sdk website but no idea what it mean. It say scheme://host:port/path or pathPrefix or pathPattern

What is the host port and path .... What does the path relate to?

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
LittleFunny
  • 7,205
  • 11
  • 71
  • 166

2 Answers2

1

1) Depends on the type of intent that was requested. See implicit vs explicit intents in the "Intent resolution" section of the docs:

http://developer.android.com/guide/topics/intents/intents-filters.html

If you name the component exactly then you know which activity will launch. Other intents name a generic action and can be matched by multiple activities. The user gets a menu asking which app they want to use to complete the action normally. For instance download the Firefox app from the Marketplace and click on a link in an email, you'll get a prompt asking if you want to use the Browser or Firefox to open the URL.

2) That's for intercepting a custom URL scheme or overlaying HTTP requests. Sounds like that not something you're interested in doing, you can safely ignore it unless you need to use it. If you do want more info about it there's a question with some good answers already:

Launch custom android application from android browser

Community
  • 1
  • 1
mikerowehl
  • 2,202
  • 1
  • 17
  • 20
  • What do we put in the scheme if I want to send custom object or string to an other activity . – LittleFunny Feb 04 '11 at 00:50
  • You don't need to use the URL form to pass data, you can just append it to the Intent: myIntent.putExtra("com.android.samples.SpecialValue", "Hello, Joe!"); // see also [http://developer.android.com/guide/appendix/faq/commontasks.html](http://developer.android.com/guide/appendix/faq/commontasks.html) – mikerowehl Feb 04 '11 at 04:55
1

1) see @mikerowehl answer

2) data is referenced through Uniform Resource Indentifiers (URI's). In Android, scheme could be http, tel, file, content (don't know about others) and by specifying a certain scheme in a filter you're saying that your component can handle data provided that way.

host+port=authority. In case of a data whose scheme is http, host will of course be something like stackoverflow.com, port will probably be left unspecified (if you're accessing a proxy it could be 8080). In case of a content provider, the authority is by convention "the fully-qualified class name of the content provider (made lowercase)", without a port.

This should be the general idea. Documentation in this field is pretty scattered but you should be able to find information on a particular task (say opening email attachments) when you'll need.

bigstones
  • 14,587
  • 6
  • 63
  • 80