I\'ve read lots of articles about intent filters and I really can\'t understand exactly what they do?
so please if anybody can explain to me with a clear example what is
Simply put, Intent filters are a way of telling the OS how to launch/communicate with the different activities/services/broadcast receivers in your app. So for example, if you want links that start with http://www.mycompany.com to lead people into your app, an intent filter is the way to accomplish that. Once its setup, anytime someone clicks on a link that starts with that (in any app) the user will be presented with the option to use your app to view that page. You've probably seen this with youtube urls. Likewise, if you want the 'share' link commonly seen in many apps to list your app, would use an intent filter to do that.
hope this helps...
Intent filter tells the android system for which intent or event the android components(activity,service ,broadcast receiver) should listen.
Intent Filters is a way of telling OS that let me handle/provide these kind of Activities/Services
By adding given filter to Manifest tells OS that i can also handle Sms service and whenever you send sms it will show in a list or you can also explicitly use this as your sms service.
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<action android:name="com.example.code.SMS_INTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="smsto" />
</intent-filter>
And to explicitly using this service call it like ...
Intent intent = new Intent("com.example.code.SMS_INTENT", Uri.parse(uri));
intent.putExtra("from", "code");
startActivity(intent);
An intent filter lets the system know what data or service requests a component can handle. A component might be an activity, service or broadcast receiver.
If you are writing an image viewer, you would add an intent filter (or several) to the manifest describing the images you can handle. If you are writing a file browser, you might package up the details of an image file in an intent, and the system would sift through intent filters until it found a best match to handle that image. The same goes for any type of data or service that might be passed from one component to the next.
IntentFilters are used to declare a pattern of Intent attributes that the declaring component will respond to. You can specify with an IntentFilter that a given Activity, Service or BroadcastReceiver will respond to a combination of action, data mime type, scheme, path, etc. For example if you register an Activity with IntentFilter for ACTION_SEND with data type "text/plain", your Activity will be called each time the users wants to send some text.
intentFilters advertise the capabilities of a component and delimit the intents that can handle. an IntentFilter that a given Activity, Service or BroadcastReceiver will respond to a combination of action, data mime type, scheme, path, etc.
The intent by comparing the intent to intent filters based on three aspects:
1:- The intent action
2:- The intent data (both URI and data type)
3:- The intent categoryaction :
Declares the intent action accepted, in the name attribute. The value must be the literal string value of an action, not the class constant.data :
Declares the type of data accepted, using one or more attributes that specify various aspects of the data URI (scheme, host, port, path, etc.) and MIME type.category :
Declares the intent category accepted, in the name attribute. The value must be the literal string value of an action, not the class constant.
For example, This activity handles "SEND" actions with text data.
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>