Data tags should only declare unique attributes
Data tags should only declare unique attributes
<intent-filter>
<data>
tags should only declare a single unique attribute (i.e. scheme OR host, but not both). This better matches the runtime behavior of intent filters, as they combine all of the declared data attributes into a single matcher which is allowed to handle any combination across attribute types.
For example, the following two <intent-filter>
declarations are the same: <intent-filter> <data android:scheme="http" android:host="example.com" /> <data android:scheme="https" android:host="example.org" /> </intent-filter> <intent-filter> <data android:scheme="http"/> <data android:scheme="https"/> <data android:host="example.com" /> <data android:host="example.org" /> </intent-filter>
They both handle all of the following:
The second one better communicates the combining behavior and is clearer to an external reader that one should not rely on the scheme/host being self contained. It is not obvious in the first that http://example.org is also matched, which can lead to confusion (or incorrect behavior) with a more complex set of schemes/hosts.
Note that this does not apply to host + port, as those must be declared in the same <data>
tag and are only associated with each other.
Issue id: IntentFilterUniqueDataAttributes
https://developer.android.com/guide/components/intents-filters
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3 |
Plugin: | Android, 2022.3.1 Beta 2 |