Closed jpobst closed 2 months ago
Proposed commit message:
Fixes: https://github.com/xamarin/xamarin-android/issues/8729
API-31 added support for a [`<property/>`][0] element within
`AndroidManifest.xml`, which can be contained within `<activity/>`,
`<application/>`, `<provider/>`, `<receiver/>`, and `<service/>`
elements.
Add a new `Android.App.PropertyAttribute` custom attribute which will
emit `<property/>` within `AndroidManifest.xml`:
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class,
AllowMultiple = true, Inherited = false)]
public partial class PropertyAttribute : Attribute {
public string Name {get;}
public string? Resource {get;}
public string? Value {get;}
public PropertyAttribute (string name);
}
Semantics otherwise appear to be identical to
`<meta-data/>`/`MetaDataAttribute`: only `Resource` or `Value` can
be specified, etc. (This is checked by `aapt2`.)
Using `[assembly:Property(…)]` will result in `<property/>` being
emitted within the `<application/>` element.
For example:
[Service (Name = "fooService", ForegroundServiceType = Android.Content.PM.ForegroundService.TypeSpecialUse)]
[Property ("android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE", Value = "explanation_for_special_use")]
public partial class FooService : Service {
}
will emit the `AndroidManifest.xml` fragment:
<service android:name="fooService" android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="explanation_for_special_use"
/>
</service>
[0]: https://developer.android.com/guide/topics/manifest/property-element
Hi, what version will it appear in?
It will be in .NET 9 Preview 7.
Fixes: https://github.com/xamarin/xamarin-android/issues/8729
Adds support for specifying the
AndroidManifest.xml
<property>
element via a new[Property]
attribute. This appears to be the exact same as<meta-data>
but with a different name, so it is implemented exactly the same.Example:
creates:
This element can be applied to
<application>
,<activity>
,<provider>
,<receiver>
, and<service>
elements.