android_manifest/category.rs
1use serde::{Deserialize, Serialize};
2
3/// Adds a category name to an intent filter.
4///
5/// See [`Intents and Intent Filters`] for details on intent filters and
6/// the role of category specifications within a filter.
7///
8/// ## XML Syntax
9/// ```xml
10/// <category android:name="string" />
11/// ```
12///
13/// ## Contained in:
14/// * [`<intent-filter>`]
15///
16/// ## Introduced in
17/// API Level 1
18///
19/// [`Intents and Intent Filters`]: https://developer.android.com/guide/components/intents-filters
20/// [`<intent-filter>`]: crate::IntentFilter
21#[derive(
22 Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
23)]
24pub struct Category {
25 /// The name of the category. Standard categories are defined in the [`Intent`]
26 /// class as CATEGORY_name constants. The name assigned here can be derived
27 /// from those constants by prefixing `"android.intent.category."` to
28 /// the name that follows CATEGORY_. For example, the string value for
29 /// CATEGORY_LAUNCHER is`"android.intent.category.LAUNCHER"`.
30 ///
31 /// ## Note
32 /// In order to receive implicit intents, you must include the
33 /// [`CATEGORY_DEFAULT`] category in the intent filter. The methods
34 /// [`startActivity()`] and [`startActivityForResult()`] treat all intents
35 /// as if they declared the [`CATEGORY_DEFAULT`] category. If you do not
36 /// declare it in your intent filter, no implicit intents will resolve to
37 /// your activity.
38 ///
39 /// Custom categories should use the package name as a prefix, to ensure that
40 /// they are unique.
41 ///
42 /// [`Intent`]: https://developer.android.com/reference/android/content/Intent
43 /// [`CATEGORY_DEFAULT`]: https://developer.android.com/reference/android/content/Intent#CATEGORY_DEFAULT
44 /// [`startActivity()`]: https://developer.android.com/reference/android/app/Activity#startActivity(android.content.Intent)
45 /// [`startActivityForResult()`]: https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)
46 #[yaserde(attribute, prefix = "android")]
47 pub name: Option<String>,
48}