Search code examples
androidcategoriesintentfilter

Purpose of android intentfilter categories


I have read from several sources regarding Categories used in IntentFilter. However, I cant seem to get a hold of what their purpose is, what the various category types mean and how are they different from actions. Could someone please explain it ?

Thanks in advance.


Solution

  • The whole intent filter mechanism is just android's way of letting you tell the system what your app is capable of. Categories are just part of that process. Activities that can be launched from the home screen will have the "launcher" category. Activities that can open files from the web will have the category "browsable".

    For a list of categories see...

    http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LAUNCHER

    Action and categories are slightly different. I think of actions as a specific declaration of what your app can do. I think of categories as broad declaration of what the app does.

    The category called CATEGORY_DEFAULT is the most confusing one to me (and I think everyone else). The android docs say "Activities will very often need to support the CATEGORY_DEFAULT so that they can be found by Context.startActivity()". Another quote is "Note also the DEFAULT category supplied here: this is required for the Context.startActivity method to resolve your activity when its component name is not explicitly specified.". I try to not focus on exactly what CATEGORY_DEFAULT means and just remember that you need it if you want to call startActivity to work right.