Could someone please explain me the purpose of Intent
categories? When should I make my own and so on? The only thing thats written about Intent
categories in my book is that they can group intents?.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
The category's alone are useless, they are used to describe a possible target for an "implicit intent" in an
intent-filter
.When you know which class/activity you want to launch and use
startActivity()
orstartActivityForResult()
, it's called an "explicit intent".Here's an analogy for how implicit intents work:
If you want to make some of your Activity/BroadcastReceivers/Services available outside of your applications bounds, you can use the Android Manifest to declare an "intent filter" to it, so it gets opened when the system or an app launches an "implicit intent" that matches.
You do this (for example) for the Activity which should be opened from the launcher:
This listens to the
ACTION_MAIN
-action triggered by Androids Launcher (CATEGORY_LAUNCHER
).You have two child-elements in your "intent filter":
action
. This specifies what action the "intent filter" should listen to.category
s. This specifies, how the activity should be called.One of the
category
s can be (for example)android.intent.category.DEFAULT
, which tells the Activity to be launched normally in full-screen-mode. Theandroid.intent.category.TAB
-category for example declares this activity as a tab in aTabActivity
, so it can only be opened as a Tab.Another example would be adding the
android.intent.category.PREFERENCE
-category, which would declare the activity as your Settings-Activity.Declaring your own
category
s is neither possible nor necessary.Further more you'll need to understand that those events are triggered by the System/Another App and you can only specify if and how you want to react when they are triggered.